logstash-plugins / logstash-output-influxdb

Apache License 2.0
58 stars 77 forks source link

influxdb outgoing plugin failed to flush outgoing items in logstash-1.5.0.beta1-1 #5

Closed evgygor closed 9 years ago

evgygor commented 9 years ago

I'm using logstash-1.5.0.beta1-1. The following errors appears in log file:

{:timestamp=>"2015-01-08T17:23:38.518000+0200", :message=>"Failed to flush outgoing items", :outgoing_count=>100, :exception=>#<NoMethodError: undefined method to_json' for #<Array:0x1b9a67a3>>, :backtrace=>["/opt/logstash/lib/logstash/outputs/influxdb.rb:191:inflush'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/stud-0.0.18/lib/stud/buffer.rb:219:inbuffer_flush'", "org/jruby/RubyHash.java:1341:ineach'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/stud-0.0.18/lib/stud/buffer.rb:216:inbuffer_flush'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/stud-0.0.18/lib/stud/buffer.rb:193:inbuffer_flush'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/stud-0.0.18/lib/stud/buffer.rb:159:inbuffer_receive'", "/opt/logstash/lib/logstash/outputs/influxdb.rb:156:inreceive'", "/opt/logstash/lib/logstash/outputs/base.rb:86:inhandle'", "(eval):255:ininitialize'", "org/jruby/RubyArray.java:1613:ineach'", "org/jruby/RubyEnumerable.java:805:inflat_map'", "(eval):252:ininitialize'", "org/jruby/RubyProc.java:271:incall'", "/opt/logstash/lib/logstash/pipeline.rb:272:inoutput'", "/opt/logstash/lib/logstash/pipeline.rb:231:inoutputworker'", "/opt/logstash/lib/logstash/pipeline.rb:160:in`start_outputs'"], :level=>:warn}

My conf file: input { file { path => [ "/opt/jmeter/bin/attsec.csv"] start_position => "beginning" type => "jmeter" } }

filter { if ([message] =~ "responseCode") { drop { } } else { csv { columns => ["timeStamp","elapsed","label","responseCode","responseMessage", "threadName","success","failureMessage","bytes","Latency", "SampleCount","ErrorCount","Hostname","IdleTime"] remove_field => ["timeStamp","responseMessage","threadName","failureMessage", "SampleCount","ErrorCount","Hostname"] add_field => { "time" => "%{timeStamp}" } } } }

output { influxdb { host => "172.20.90.72" password => "root" user => "root" db => "metrics" series => "%{label}" allow_time_override => true time_precision => "m" coerce_values => { "time" => "integer" "elapsed" => "integer" "Latency" => "integer" "bytes" => "integer" "IdleTime" => "integer" } data_points => { "time" => "%{time}" "elapsed" => "%{elapsed}" "Latency" => "%{Latency}" "bytes" => "%{bytes}" "IdleTime" => "%{IdleTime}" "responseCode" => "%{responseCode}" "success" => "%{success}" } } }

evgygor commented 9 years ago

Actually, I tried the solution from http://stackoverflow.com/questions/3731920/undefined-method-to-json-for-hash0x3d3cef0-nomethoderror-in-activesuppor

=> Adding require "active_support/core_ext" to the influxdb.rb.

I retested the issue - no errors in log file, data arrived to the influxdb as well.

Thanks

xpajaro commented 9 years ago

@evgygor I tried your solution with logstash 1.2 rc2 and I can't successfully run Influxdb anymore. Here's my error:

" Couldn't find any output plugin named 'influxdb'. Are you sure this is correct? Trying to load the influxdb output plugin resulted in this error: no such file to load -- active_support/core_ext"

Without the fix you recommended, Logstash starts and takes input but the error I'm getting is this:

Failed to flush outgoing items {:outgoing_count=>1, :exception=>#<NoMethodError: undefined method to_json' for #<Array:0x5ff935cb>>, :backtrace=>["/logstash15/vendor/bundle/jruby/1.9/gems/logstash-output-influxdb-0.1.3/lib/logstash/outputs/influxdb.rb:190:inflush'", "/logstash15/vendor/bundle/jruby/1.9/gems/stud-0.0.19/lib/stud/buffer.rb:219:inbuffer_flush'", "org/jruby/RubyHash.java:1341:ineach'", "/logstash15/vendor/bundle/jruby/1.9/gems/stud-0.0.19/lib/stud/buffer.rb:216:inbuffer_flush'", "/logstash15/vendor/bundle/jruby/1.9/gems/stud-0.0.19/lib/stud/buffer.rb:193:inbuffer_flush'", "/logstash15/vendor/bundle/jruby/1.9/gems/stud-0.0.19/lib/stud/buffer.rb:159:inbuffer_receive'", "/logstash15/vendor/bundle/jruby/1.9/gems/logstash-output-influxdb-0.1.3/lib/logstash/outputs/influxdb.rb:155:inreceive'", "/logstash15/lib/logstash/outputs/base.rb:88:inhandle'", "(eval):27:ininitialize'", "org/jruby/RubyProc.java:271:incall'", "/logstash15/lib/logstash/pipeline.rb:279:inoutput'", "/logstash15/lib/logstash/pipeline.rb:235:inoutputworker'", "/logstash15/lib/logstash/pipeline.rb:163:instart_outputs'"], :level=>:warn}

Can anyone help with this, please?

evgygor commented 9 years ago

logstash 1.2 rc2 ? not 1.5?

xpajaro commented 9 years ago

@evgygor pardon, I meant 1.5

xpajaro commented 9 years ago

I fixed the error by adding the json dependency to the influxdb.rb file

 require "json"
suyograo commented 9 years ago

@xpajaro thanks for debugging. Could you please create a PR for this and we can merge it in?

xpajaro commented 9 years ago

@suyograo it was already done here: https://github.com/logstash-plugins/logstash-output-influxdb/pull/8

evgygor commented 9 years ago

That is a solution.