Logstash version: 6.4.2
I have this code for a ruby in filter {...}:
ruby {
code => 'event.set("logstash_time_difference", (((event.get("[received_at]").to_f - event.get("[@timestamp]").to_f).abs)*1000).round(0));'
}
This code works just fine. I have no problem with it.
I wanted the change the name of the field to: "log_received_time_diff_ms"
However when i do that and change the above code to:
ruby {
code => 'event.set("log_recieved_time_diff_ms", (((event.get("[received_at]").to_f - event.get("[@timestamp]").to_f).abs)*1000).round(0));'
}
Logstash fails to process anything and keeps crashing filling the logs with the following:
[2019-01-30T17:40:19,651][ERROR][logstash.pipeline ] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. {:pipeline_id=>"main", "exception"=>"undefined method >=' for nil:NilClass", "backtrace"=>["(eval):759:in
block in initialize'", "org/jruby/RubyArray.java:1734:in each'", "(eval):757:in
block in initialize'", "(eval):307:in block in filter_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:341:in
filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:320:in worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:286:in
block in start_workers'"], :thread=>"#<Thread:0x4ac4fc87 sleep>"}
The above repeats for about a few dozen times and then ends with this:
[2019-01-30T17:40:19,795][FATAL][logstash.runner ] An unexpected error occurred! {:error=>#<NoMethodError: undefined method >=' for nil:NilClass>, :backtrace=>["(eval):759:in
block in initialize'", "org/jruby/RubyArray.java:1734:in each'", "(eval):757:in
block in initialize'", "(eval):307:in block in filter_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:341:in
filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:320:in worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:286:in
block in start_workers'"]}
[2019-01-30T17:40:19,854][ERROR][org.logstash.Logstash ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit
At which point logstash restarts.
If I change that original line to any other field name but "logstash_time_difference" even just deleting a single letter or adding a letter, this problem occurs.
If I change back to that field it works again.
Also, I can change the math in the line and it seems to have no problem, it appears to only keep failing changing the field name.
I can't tell what is wrong based on these entries.
Can anyone give some advice?
Edit:
I also tried making the new field with add_field above this line, but it didn't change anything.
Thanks.