Logstash MongoDB Output Plugin - command insert requires authentication

I'm using logstash 7.10.2 with MongoDB logstash-output plugin (tested 2 diff versions), I'm trying to write documents from elastic to mongodb, however I'm getting the following errors for each version,

plugin version logstash-output-mongodb (3.1.5)

[2021-03-24T16:28:04,774][DEBUG][logstash.outputs.mongodb ][main][875e71ebe6badsfddsdf06ff929e4fasadfsd34535435b35sdfsd919asfdsafsf9c] MONGODB | COMMAND | namespace=MyMongoDB.$cmd selector={:insert=>"myMongoCollection", :docu
ments=>[{"field_1"=>"value", "@version"=>"1", "@timestamp"=>"\"2021-03-24T20:27:43.100Z\"", "field_2"=>"value", "field_3"=>"value", "field_4"=>"value", ... flags=[] limit=-1 skip=0 project=nil | runtime: 0.0000ms

exception=>#<Mongo::Auth::Unauthorized: User ABC123 is not authorized to access MyMongoDB.>
<Mongo::Error::OperationFailure: command insert requires authentication (13)>

plugin version logstash-output-mongodb (3.1.6)

}
[2021-03-24T17:00:16,871][WARN ][logstash.outputs.mongodb ][main] MONGODB | Failed to handshake with myMongoDB-server.com:1234: ArgumentError: wrong number of arguments (given 2, expected 1)
[2021-03-24T17:00:16,871][WARN ][logstash.outputs.mongodb ][main] MONGODB | Error running ismaster on myMongoDB-server.com:1234: ArgumentError: wrong number of arguments (given 2, expected 1)
[2021-03-24T17:00:16,886][DEBUG][logstash.outputs.mongodb ][main] MONGODB | Server description for myMongoDB-server.com:1234changed from 'unknown' to 'unknown'.

the user that I'm providing in the uri connection has privileges to add documents, I've tested manually via MongoDB Compass UI.

Any suggestion if this is a bug in the plugins ?

It pretty much has to be, but where to start looking? If you look at the issues for the plugin it comes up from time to time. Some of them appear to be version dependencies where an underlying library change their interfaces.

Here is an example from last year that turned out to be in the mongodb client code.

Last year another user had a similar issue. I pointed them at an unmerged PR and they said they would try to build it themselves. No indication whether that worked.

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