# I can't send MongoDB data to Elasticseach via logstash

**URL:** <https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976>\
**Category:** Logstash\
**Created:** [May 29, 2020, 7:18pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976 "2020-05-29T19:18:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FernandoMOTA](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@FernandoMOTA](https://discuss.elastic.co/u/FernandoMOTA)\
**Post date:** [May 29, 2020, 7:18pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976/1 "2020-05-29T19:18:08Z")

</div>

My configuration file is as follows:

```
    input {
  mongodb {
        uri => 'mongodb://localhost:27017/exemplo'
        placeholder_db_dir => 'C:/Users/Administrator/Documents/Elastic/logstash-7.6.1/data/opt/logstash-mongodb/'
        placeholder_db_name => 'logstash_sqlite.db'
        #database =>'br'        
        #unpack_mongo_id => true
        collection => 'movie'
        batch_size => 5000

  }
}
output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "aminhaindexcaraisxsxsx"
  }
}

```

The following appears in the terminal, but does not create the index, much less receive the data

```
D, [2020-05-29T12:37:57.903000 #3572] DEBUG -- : MONGODB | [141] localhost:27017 #1 | exemplo.find | STARTED | {"find"=>"movie", "filter"=>{"_id"=>{"$gt"=>BSON::ObjectId('5ed11391474a8677a9bf3882')}}, "limit"=>5000, "$db"=>"exemplo", "lsid"=>{"id"=><BSON::Binary:0x2064 type=uuid data=0x9f9103ab597f4342...>}}
D, [2020-05-29T12:37:57.907000 #3572] DEBUG -- : MONGODB | [141] localhost:27017 | exemplo.find | SUCCEEDED | 0.002s
D, [2020-05-29T12:37:58.025000 #3572] DEBUG -- : MONGODB | [142] localhost:27017 #1 | exemplo.listCollections | STARTED | {"listCollections"=>1, "cursor"=>{}, "nameOnly"=>true, "$db"=>"exemplo", "lsid"=>{"id"=><BSON::Binary:0x2064 type=uuid data=0x9f9103ab597f4342...>}}
D, [2020-05-29T12:37:58.029000 #3572] DEBUG -- : MONGODB | [142] localhost:27017 | exemplo.listCollections | SUCCEEDED | 0.002s
```

---

<div class="post-metadata">

**Author:** ![FernandoMOTA](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@FernandoMOTA](https://discuss.elastic.co/u/FernandoMOTA)\
**Post date:** [June 1, 2020, 1:13pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976/2 "2020-06-01T13:13:08Z")

</div>

Can someone help me?

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_kumar4/32/67369_2.png) [@Rahul\_Kumar4](https://discuss.elastic.co/u/Rahul_Kumar4)\
**Post date:** [June 1, 2020, 2:07pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976/3 "2020-06-01T14:07:58Z")

</div>

Do you see any logs in Logstash that show any error as it tries to index your mongodb data in Elasticsearch?

> [@FernandoMOTA](#):
>
> `hosts => ["localhost:9200"]`

It appears that your host variable may not be set correctly. See the examples [here.](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-hosts)

You can also set up a [`stdout`](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-stdout.html) in your output plugin to see if you get any data from Mongodb.

---

<div class="post-metadata">

**Author:** ![FernandoMOTA](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@FernandoMOTA](https://discuss.elastic.co/u/FernandoMOTA)\
**Post date:** [June 1, 2020, 2:35pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976/4 "2020-06-01T14:35:57Z")

</div>

Thank you very much for answering me.

I changed my file to the following:

```
input {

  mongodb {

        uri => 'mongodb://localhost:27017/exemplo'

        placeholder_db_dir => 'C:/Users/Administrator/Documents/Elastic/logstash-7.6.1/data/opt/logstash-mongodb/'

        placeholder_db_name => 'logstash_sqlite.db'

        #database =>'br'        

        #unpack_mongo_id => true

        collection => 'movie'

        batch_size => 5000

  }

}

output {

  elasticsearch {

    hosts => ["http://localhost:9200"]

    index => "aminhaindexcaraisxsxsx"

  }

  stdout { codec => json }

}

```

Logstash displays the following response, without an error:

```
D, [2020-06-01T07:33:35.814000 #276] DEBUG -- : MONGODB | [202] localhost:27017 #1 | exemplo.find | STARTED | {"find"=>"movie", "filter"=>{"_id"=>{"$gt"=>BSON::ObjectId('5ed11391474a8677a9bf3882')}}, "limit"=>5000, "$db"=>"exemplo", "lsid"=>{"id"=><BSON::Binary:0x2064 type=uuid data=0xc8d0b628481c4ec2...>}}
D, [2020-06-01T07:33:35.838000 #276] DEBUG -- : MONGODB | [202] localhost:27017 | exemplo.find | SUCCEEDED | 0.015s
D, [2020-06-01T07:33:35.947000 #276] DEBUG -- : MONGODB | [203] localhost:27017 #1 | exemplo.listCollections | STARTED | {"listCollections"=>1, "cursor"=>{}, "nameOnly"=>true, "$db"=>"exemplo", "lsid"=>{"id"=><BSON::Binary:0x2064 type=uuid data=0xc8d0b628481c4ec2...>}}
D, [2020-06-01T07:33:35.955000 #276] DEBUG -- : MONGODB | [203] localhost:27017 | exemplo.listCollections | SUCCEEDED | 0.003s

```

But he doesn't create the index when I check Kibana, in the logstash response he even takes the ID of an object from the DB document.

Could you help me?

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_kumar4/32/67369_2.png) [@Rahul\_Kumar4](https://discuss.elastic.co/u/Rahul_Kumar4)\
**Post date:** [June 1, 2020, 3:03pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976/5 "2020-06-01T15:03:37Z")

</div>

> [@FernandoMOTA](#):
>
> ```auto
> D, [2020-06-01T07:33:35.814000 #276] DEBUG -- : MONGODB | [202] localhost:27017 #1 | exemplo.find | STARTED | {"find"=>"movie", "filter"=>{"_id"=>{"$gt"=>BSON::ObjectId('5ed11391474a8677a9bf3882')}}, "limit"=>5000, "$db"=>"exemplo", "lsid"=>{"id"=><BSON::Binary:0x2064 type=uuid data=0xc8d0b628481c4ec2...>}}
> D, [2020-06-01T07:33:35.838000 #276] DEBUG -- : MONGODB | [202] localhost:27017 | exemplo.find | SUCCEEDED | 0.015s
> D, [2020-06-01T07:33:35.947000 #276] DEBUG -- : MONGODB | [203] localhost:27017 #1 | exemplo.listCollections | STARTED | {"listCollections"=>1, "cursor"=>{}, "nameOnly"=>true, "$db"=>"exemplo", "lsid"=>{"id"=><BSON::Binary:0x2064 type=uuid data=0xc8d0b628481c4ec2...>}}
> D, [2020-06-01T07:33:35.955000 #276] DEBUG -- : MONGODB | [203] localhost:27017 | exemplo.listCollections | SUCCEEDED | 0.003s
> 
> ```

Those seem to be logs from your Mongodb. What do you see in the logstash logs?

---

<div class="post-metadata">

**Author:** ![FernandoMOTA](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@FernandoMOTA](https://discuss.elastic.co/u/FernandoMOTA)\
**Post date:** [June 1, 2020, 3:17pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976/6 "2020-06-01T15:17:42Z")

</div>

In the logs it returns like this:

```
[2020-06-01T08:00:54,265][INFO][logstash.inputs.mongodb][main] Registering MongoDB input
[2020-06-01T08:00:57,828][INFO][logstash.inputs.mongodb][main] init placeholder for logstash_since_movie: {"_id"=>BSON::ObjectId('5ed11391474a8677a9bf3882'), "name"=>"tutorials point"}
[2020-06-01T08:00:57,849][INFO][logstash.javapipeline][main] Pipeline started {"pipeline.id"=>"main"}
[2020-06-01T08:00:58,357][INFO][logstash.agent] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2020-06-01T08:00:59,014][INFO][logstash.agent] Successfully started Logstash API endpoint {:port=>9600}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 29, 2020, 3:17pm UTC](https://discuss.elastic.co/t/i-cant-send-mongodb-data-to-elasticseach-via-logstash/234976/7 "2020-06-29T15:17:44Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
