Unable to start logstash using mongoDB config? -


i using logstash-1.5.2 mongodb 3.0.4. , trying start logstash below configuration not working.


input{     stdin{     } }  output {   mongodb {     database => "logdb"         collection => "plain"      uri => "mongodb://localhost:27017"    } } 

i facing below errror :

./logstash -f conf/mongo.conf

the error reported is: uninitialized constant mongo::uriparser

please help.

the problem caused bug in latest version of logstash-output-mongodb. please see issue reported on github. can fixed changing few lines inside mongodb plugin. (please careful, hacky solution neither supports authentication nor remote servers.)

change lines of mongo.rb file mentioned here. (path should /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-mongodb-0.1.4/lib/logstash/outputs/mongodb.rb can find exact path in error message.)

replace:

    uriparsed=mongo::uriparser.new(@uri)     conn = uriparsed.connection({})     if uriparsed.auths.length > 0       uriparsed.auths.each |auth|         if !auth['db_name'].nil?           conn.add_auth(auth['db_name'], auth['username'], auth['password'], nil)         end        end       conn.apply_saved_authentication()     end     @db = conn.db(@database) 

by:

    client = mongo::client.new([ '127.0.0.1:27017' ])     @db = client.use(@database) 

and replace:

@db.collection(event.sprintf(@collection)).insert(document) 

by:

@db.database.collection(event.sprintf(@collection)).insert_one(document) 

i had issue myself in several logstash setups. changing lines did trick me everytime.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -