title: Sync data between Mongodb and ElasticSearch using Logstash
body: <p>I am trying to sync my MongoDB database with elasticsearch and use the data on Kibana. I am using the plugins  l<strong>ogstash-input-mongoDb</strong> and <strong>logstash-output-elasticsearch</strong>.</p>
  <p>The issue is in the configuration file in Logstash to connect to MongoDB. Once I setup both plugins I created a config file to mention the input source details (MongoDB) and output (ElasticSearch). I have written it here:</p>
  <pre><code>input {
         uri =&gt; 'mongodb://localhost:27017/t_data/data'
         placeholder_db_dir =&gt; '/opt/logstash-mongodb/'
         placeholder_db_name =&gt; 'logstash_sqlite.db'
         collection =&gt; 't_data'
         batch_size =&gt; 5000
  }
  
  filter {
  }
  
  output {
          stdout {
                  codec =&gt; rubydebug
         }
         elasticsearch {
                 action =&gt; &quot;index&quot;
                 index =&gt; &quot;mongo_t_data&quot;
                 hosts =&gt; [&quot;localhost:9200&quot;]
         }
  }
  </code></pre>
  <p>I then run this command from the <em>bin</em> directory in logstash where the config file is saved as <strong>mongodata.conf</strong>:</p>
  <pre><code> \logstash-7.10.1\bin&gt;logstash -f mongodata.conf
  </code></pre>
  <p>I obtain the following error:</p>
  <pre><code> [2021-01-17T00:11:22,730][ERROR][logstash.agent           ] Failed to execute action 
   {:action=&gt;LogStash::PipelineAction::Create/pipeline_id:main, 
   :exception=&gt;&quot;LogStash::ConfigurationError&quot;, :message=&gt;&quot;Expected one of [ \\t\\r\\n], \&quot;#\&quot;, \&quot;{\&quot; at 
   line 2, column 13 (byte 22) after input {\r\n        uri &quot;, :backtrace=&gt;[&quot;C:/PESU/logstash-7.10.1- 
   windows-x86_64/logstash-7.10.1/logstash-core/lib/logstash/compiler.rb:32:in `compile_imperative'&quot;, 
   &quot;org/logstash/execution/AbstractPipelineExt.java:184:in `initialize'&quot;, 
   &quot;org/logstash/execution/JavaBasePipelineExt.java:69:in `initialize'&quot;, &quot;C:/PESU/logstash-7.10.1- 
   windows-x86_64/logstash-7.10.1/logstash-core/lib/logstash/java_pipeline.rb:47:in `initialize'&quot;, 
   &quot;C:/PESU/logstash-7.10.1-windows-x86_64/logstash-7.10.1/logstash- 
   core/lib/logstash/pipeline_action/create.rb:52:in `execute'&quot;, &quot;C:/PESU/logstash-7.10.1-windows- 
   x86_64/logstash-7.10.1/logstash-core/lib/logstash/agent.rb:365:in `block in converge_state'&quot;]}
   [2021-01-17T00:11:23,310][INFO ][logstash.agent           ] Successfully started Logstash API 
   endpoint {:port=&gt;9600}
   [2021-01-17T00:11:28,026][INFO ][logstash.runner          ] Logstash shut down.
   [2021-01-17T00:11:28,058][ERROR][org.logstash.Logstash    ] java.lang.IllegalStateException: 
   Logstash stopped processing because of an error: (SystemExit) exit
  </code></pre>
  <p>I have attached the screenshot here: <a href="https://i.stack.imgur.com/kiVAU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kiVAU.png" alt="enter image description here" /></a></p>
  <p>My goal is to get logstash connected to Mongodata and elasticsearch succesfully to be able to sync data and add documents when required. I suspect it is an issue with me using <strong>Notepad</strong> to create the .conf file.</p>