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

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"
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

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