logstash-plugins / logstash-output-mongodb

Apache License 2.0
36 stars 77 forks source link

Mongo::Error::NoServerAvailable: No server is available matching preference #44

Closed irom77 closed 6 years ago

irom77 commented 7 years ago

Getting Error::NoServerAvailable: , my output is pretty simple and mono uri verified, please advise

output {
   if [type] == "threat" {
      # Use mongodb to store logstash event.
      mongodb {
         database => "meteor"
         uri => "mongodb://mongo:27017/meteor"
         collection => "syslog" 
      }
   }

}

More details here https://discuss.elastic.co/t/logstash-output-mongodb-error-noserveravailable/97457. I am running Logstash 5.5

StephenOTT commented 6 years ago

@irom77 did you resolve the issue?

irom77 commented 6 years ago

not really, I switched to kafka..

StephenOTT commented 6 years ago

@irom77 thanks. seems like plugin is mostly abandoned / not used much.

irom77 commented 6 years ago

Thnx for letting me know

array42-zz commented 6 years ago

Maybe try creating the database and collection first manually.

Just to mention it: That error also shows up for mongoid with rails. It disappears, after you run rails server once.

So.. I don't think this is 'error' specific for this plugin. If it is, then run the code that sets up the database and collections, and after that, it may work. I don't use this plugin. As I said, just mentioning..

Also, the server config should consider if it is a replica set or a direct connection and other parameters, which you probably left out.

TomK32 commented 5 years ago

I had this problem as well back in 2017 and found errors/inconsistencies with the host names of my replica-set (hey, I'm a dev not a sys-admin) and the mongoid config.

So, check if your servers can see and access each other and if the replica-set is set correctly in you configuration. Some more information can be found in my blog: https://tomk32.de/2017/07/19/mongo-error-noserveravailable-a-few-possible-causes.html

davidhscope commented 4 years ago

Dear,

I have the same problem!!! please help me!!

singhksandeep25 commented 4 years ago

I faced the same problem, and found the culprit to be an outdated version of mongo ruby driver being used. I fixed it by upgrading the mongo version in the .gemspec file and downgrading bson version to 4.8.2. Then compiled it using jruby, via the steps mentioned in the readme. I have put up the final, installable plugin here https://github.com/singhksandeep25/logstash-output-mongodb/releases/tag/v3.1.7

ribamartins commented 2 years ago

Tks @singhksandeep25 . You saved my life