# Logstash.inputs.mongodb, fail \<BSON::ObjectId::Invalid: '1' is an invalid ObjectId.\>

**URL:** https://discuss.elastic.co/t/logstash-inputs-mongodb-fail-bson-1-is-an-invalid-objectid/215570
**Category:** Logstash
**Created:** [January 18, 2020, 5:44pm UTC](https://discuss.elastic.co/t/logstash-inputs-mongodb-fail-bson-1-is-an-invalid-objectid/215570 "2020-01-18T17:44:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![angelma83](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@angelma83](https://discuss.elastic.co/u/angelma83)
#### Post date: [January 18, 2020, 5:44pm UTC](https://discuss.elastic.co/t/logstash-inputs-mongodb-fail-bson-1-is-an-invalid-objectid/215570/1 "2020-01-18T17:44:10Z")

</div>

HI everybody,

i am using logstash-input-mongodb, and i have the following mistake,

[logstash.inputs.mongodb] MongoDB Input threw an exception, restarting {:exception=\>#\<BSON::ObjectId::Invalid: '1' is an invalid ObjectId.\>}

Please can anybody help me.

thanks in advance  
best regards

---

<div class="post-metadata">

### Author: ![Ramicoh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramicoh/32/61017_2.png) [@Ramicoh](https://discuss.elastic.co/u/Ramicoh)
#### Post date: [January 21, 2020, 10:33pm UTC](https://discuss.elastic.co/t/logstash-inputs-mongodb-fail-bson-1-is-an-invalid-objectid/215570/2 "2020-01-21T22:33:56Z")

</div>

There are a few options.  
You would need to check if the ID is a valid one.  
See this question:

> <https://stackoverflow.com/questions/7483089/wrong-objectid-in-mongo>

You could also remove and add this ID again using `db.collection.remove({"_id":"yourInvalidId"})`.

Let me know if this helped 🙂

---

<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: [February 18, 2020, 10:38pm UTC](https://discuss.elastic.co/t/logstash-inputs-mongodb-fail-bson-1-is-an-invalid-objectid/215570/3 "2020-02-18T22:38:53Z")

</div>

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