logstash-plugins / logstash-filter-mutate

Apache License 2.0
16 stars 75 forks source link

Logstash 6.2.3 convert_float doesn't check to see if value is a string #120

Closed dougburks closed 6 years ago

dougburks commented 6 years ago

I noticed that this recent change adds tr to the convert functions: https://github.com/logstash-plugins/logstash-filter-mutate/commit/3958b72ac05d004926058111da3f1493324ac766

However, it looks like convert_float doesn't check to see if the value is a string the way that convert_integer does: https://github.com/logstash-plugins/logstash-filter-mutate/blob/master/lib/logstash/filters/mutate.rb#L336-L345

Does convert_float need to be updated?

Thanks!

raimundmuc commented 6 years ago

Yes, you are right, otherwise Logstash crashes with:

An unexpected error occurred! {:error=>#<NoMethodError: undefined method 'tr' for 0.001:Float>, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-filter-mutate-3.3.1/lib/logstash/filters/mutate.rb:344:in 'convert_float'", [...]

Anish841 commented 6 years ago

Whats Fix for this ?

autarchprinceps commented 6 years ago

@Anish841 Only doing tr, when the value to be converted is a string. The same was done in convert_int already. I have uploaded that as a pull request, but so far no response.

gmoskovicz commented 6 years ago

This can easily be reproduced:

input {
  generator {
        lines => ['{ "field1" : 222 }']
  }
}

filter {
     json { source => message }
      mutate {
        convert => [ "field1", "float"]
      }

}
output {
        stdout { codec => rubydebug }
}
yaauie commented 6 years ago

Version 3.3.2 of the Mutate Filter Plugin includes a fix; to use it with an existing installation of Logstash, you can use the logstash-plugin utility:

bin/logstash-plugin update logstash-filter-mutate
taraso commented 6 years ago

I had the same issue with logstash 6.2.4, after upgrading mutate, i get this:

[2018-05-09T18:22:01,177][FATAL][logstash.runner          ] An unexpected error occurred! {:error=>#<NameError: undefined local variable or method `dotfile' for #<AwesomePrint::Inspector:0x195251a2>
Did you mean?  @@dotfile>, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/awesome_print-1.8.0/lib/awesome_print/inspector.rb:163:in `merge_custom_defaults!'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/awesome_print-1.8.0/lib/awesome_print/inspector.rb:50:in `initialize'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/kernel.rb:9:in `ai'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-codec-rubydebug-3.0.5/lib/logstash/codecs/rubydebug.rb:39:in `encode_default'", "org/jruby/RubyMethod.java:115:in `call'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-codec-rubydebug-3.0.5/lib/logstash/codecs/rubydebug.rb:35:in `encode'", "/usr/share/logstash/logstash-core/lib/logstash/codecs/base.rb:50:in `block in multi_encode'", "org/jruby/RubyArray.java:1734:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/codecs/base.rb:50:in `multi_encode'", "/usr/share/logstash/logstash-core/lib/logstash/outputs/base.rb:90:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/single.rb:15:in `block in multi_receive'", "org/jruby/ext/thread/Mutex.java:148:in `synchronize'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/single.rb:14:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator.rb:49:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:477:in `block in output_batch'", "org/jruby/RubyHash.java:1343:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:476:in `output_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:428:in `worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:386:in `block in start_workers'"]}
[2018-05-09T18:22:01,278][ERROR][org.logstash.Logstash    ] java.lang.IllegalStateException: org.jruby.exceptions.RaiseException: (SystemExit) exit
yaauie commented 6 years ago

:weary: it looks like the version of awesome_print we rely on has a long-standing bug where it throws an error trying to load its own configuration if your environment variable HOME is unset, and the clause that's meant to handle errors also throws the above error

martinduris commented 6 years ago

Hi, today we migrated to logstash 6.2.4. Same problem here. Workaround: usr/share/logstash# bin/logstash-plugin install --version 3.2.0 logstash-filter-mutate (thanks to this post https://stackoverflow.com/questions/49976026/logtash-undefined-method-tr) (downgrade to version of mutate filter used in logstash 6.0.0)

Do we know if new version of logstash would be fixed ?

Thanks

edperry commented 6 years ago

Any hope of 6.2.5 coming soon? don't like doing plugin installs as our firewall block it all, and it is a pain to handle for +200 servers

raimundmuc commented 6 years ago

Is there any chance that this bugfix will find its way into the release version? Logstash 6.3.0 of today is still broken :-(

jffree commented 6 years ago

Is this bug fixed? I also encountered this problem.

yaauie commented 6 years ago

Version 3.3.2 of this plugin includes the fix and was shipped with Logstash 6.3.2.

KeithTt commented 3 years ago

Finally I found this, the logstash is writing log madly...

Update logstash-filter-mutate plugin of all logstash instances and then it works.