# MongoDB Input threw an exception, restarting {:exception=\>#\<BSON::ObjectId::Invalid:

**URL:** https://discuss.elastic.co/t/mongodb-input-threw-an-exception-restarting-exception-bson/217302
**Category:** Logstash
**Created:** [January 31, 2020, 6:33am UTC](https://discuss.elastic.co/t/mongodb-input-threw-an-exception-restarting-exception-bson/217302 "2020-01-31T06:33:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Raghala\_Purushotham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raghala_purushotham/32/61810_2.png) [@Raghala\_Purushotham](https://discuss.elastic.co/u/Raghala_Purushotham)
#### Post date: [January 31, 2020, 6:33am UTC](https://discuss.elastic.co/t/mongodb-input-threw-an-exception-restarting-exception-bson/217302/1 "2020-01-31T06:33:22Z")

</div>

Hi,

I am trying to import the data from MongoDB to Elastic. As part of that, I am using the "logstash-input-mongodb" as an input plugin. But I am facing the below error while importing it.

## Conf file:

input {  
mongodb {  
uri =\> 'mongodb://localhost:27017/dbname'  
placeholder\_db\_dir =\> '/tmp'  
placeholder\_db\_name =\> 'logstash\_sqlite.db'  
collection =\> 'Entity$'  
batch\_size =\> 5000  
}  
}  
output {  
elasticsearch {  
hosts =\> "[http://localhost:9200](http://localhost:9200)"  
index =\> "suspicious"  
}  
}

## MongoDB data set:

{ "\_id" : "04ec4fb4-f49c-4136-a980-3d7fe3bf1635", "name" : "bob" }  
{ "\_id" : "16172af2-e56f-4573-9940-f762a4fbb4ba", "name" : "foo" }

## Error:

[2020-01-31T10:53:25,480][DEBUG][logstash.inputs.mongodb] Tailing MongoDB  
[2020-01-31T10:53:25,482][DEBUG][logstash.inputs.mongodb] Collection data is: {"SuspiciousEntity"=\>{:name=\>"Entity", :last\_id=\>"04ec4fb4-f49c-4136-a980-3d7fe3bf1635"}}  
[2020-01-31T10:53:25,489][DEBUG][logstash.inputs.mongodb] collection\_data is: {"Entity"=\>{:name=\>"Entity", :last\_id=\>"04ec4fb4-f49c-4136-a980-3d7fe3bf1635"}}  
[2020-01-31T10:53:25,499][WARN][logstash.inputs.mongodb] MongoDB Input threw an exception, restarting {:exception=\>#\<BSON::ObjectId::Invalid: '04ec4fb4-f49c-4136-a980-3d7fe3bf1635' is an invalid ObjectId.\>}  
[2020-01-31T10:53:25,500][DEBUG][logstash.inputs.mongodb] collection\_data is: {"Entity"=\>{:name=\>"Entity", :last\_id=\>"04ec4fb4-f49c-4136-a980-3d7fe3bf1635"}}  
[2020-01-31T10:53:25,501][WARN][logstash.inputs.mongodb] MongoDB Input threw an exception, restarting {:exception=\>#\<BSON::ObjectId::Invalid: '04ec4fb4-f49c-4136-a980-3d7fe3bf1635' is an invalid ObjectId.\>}  
[2020-01-31T10:53:25,502][DEBUG][logstash.inputs.mongodb] collection\_data is: {"Entity"=\>{:name=\>"Entity", :last\_id=\>"04ec4fb4-f49c-4136-a980-3d7fe3bf1635"}}

Please someone reply me.

@magnusbaeck @shubhamblackstratus

---

<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 28, 2020, 6:33am UTC](https://discuss.elastic.co/t/mongodb-input-threw-an-exception-restarting-exception-bson/217302/2 "2020-02-28T06:33:24Z")

</div>

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