# Mongodb input plugin for logstash missing data problem

**URL:** <https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272>\
**Category:** Logstash\
**Created:** [August 1, 2017, 3:36am UTC](https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272 "2017-08-01T03:36:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TaurusD](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@TaurusD](https://discuss.elastic.co/u/TaurusD)\
**Post date:** [August 1, 2017, 3:36am UTC](https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272/1 "2017-08-01T03:36:05Z")

</div>

Hi, I'm using logstash-input-mongodb to import my data from mongodb to ELK.  
But when it was done, I found that there is one document missing (I have 17781 docs in mongodb but only got 17780 docs in ELK).

I used the "normal" way to install the plugin through command `bin\logstash-plugin install logstash-input-mongo`.  
So can anyone help me on this problem?

Also, I found that when there is a change on the source db in mongo, this plugin can not detect it and import new data. And I didn't found any schedule settings (like jdbc input plugin) which allow me to call my data regularly. So can anyone tell me how to keep data updated with mongodb using this plugin?

Thank you!

---

<div class="post-metadata">

**Author:** ![TaurusD](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@TaurusD](https://discuss.elastic.co/u/TaurusD)\
**Post date:** [August 1, 2017, 3:40am UTC](https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272/2 "2017-08-01T03:40:18Z")

</div>

@magnusbaeck @val  
Hi, experts. Could you please give me some advice?

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [August 1, 2017, 10:13am UTC](https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272/3 "2017-08-01T10:13:20Z")

</div>

It appears from this line:

```auto
return collection.find({:_id => {:$gt => last_id_object}}).limit(batch_size)

```

that the plugin only finds documents based on increasing object\_id, meaning it will not see modified documents.

I see you have created an issue on the github repo.

> <https://github.com/phutchins/logstash-input-mongodb/issues/71>

---

<div class="post-metadata">

**Author:** ![TaurusD](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@TaurusD](https://discuss.elastic.co/u/TaurusD)\
**Post date:** [August 1, 2017, 10:29am UTC](https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272/4 "2017-08-01T10:29:14Z")

</div>

First of all, thank you for your replying me.  
I've also tried to add a document manually, and the plugin still didn't react to my work.

P.S. the post on Github is also created by me. 😉

---

<div class="post-metadata">

**Author:** ![TaurusD](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@TaurusD](https://discuss.elastic.co/u/TaurusD)\
**Post date:** [August 4, 2017, 6:20am UTC](https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272/5 "2017-08-04T06:20:21Z")

</div>

Hi @guyboertje, I also saw a pull request [#60](https://github.com/phutchins/logstash-input-mongodb/pull/60) trying to solve this bug, but seems no update till now.

It would be already clear that the missing doc is the first one, namely, the one with the smallest `_id`.  
I currently solve this problem by adding a placeholder doc to take the first place, which works but not convenient I think.

Moreover, I have also tried to add a new doc, whose `_id` would be the largest, while logstash is importing through mongo input plugin. The result is logstash didn't react to the new doc. Do you know how to solve?

Thank you!

---

<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:** [September 1, 2017, 6:20am UTC](https://discuss.elastic.co/t/mongodb-input-plugin-for-logstash-missing-data-problem/95272/6 "2017-09-01T06:20:22Z")

</div>

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