Hello Everyone,
I am getting below error while trying to produce new event from existing one as follows, any help?
ruby { code => "event['new_field'] = event.get['dummy'][1..4]" }
Error:
Ruby exception occurred: undefined method
[]' for nil:NilClass {:class=>"NoMethodError", :backtrace=>["(ruby filter code):2:in
block in filter_method'", "./LOGSTASH/logstash-7.16.1/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.7/lib/logstash/filters/ruby.rb:93:ininline_script'", "./LOGSTASH/logstash-7.16.1/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.7/lib/logstash/filters/ruby.rb:86:in
filter'", "./LOGSTASH/logstash-7.16.1/logstash-core/lib/logstash/filters/base.rb:159:indo_filter'", "./LOGSTASH/logstash-7.16.1/logstash-core/lib/logstash/filters/base.rb:178:in
block in multi_filter'", "org/jruby/RubyArray.java:1821:ineach'", "/evam/LOGSTASH/logstash-7.16.1/logstash-core/lib/logstash/filters/base.rb:175:in
multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:134:inmulti_filter'", "./LOGSTASH/logstash-7.16.1/logstash-core/lib/logstash/java_pipeline.rb:299:in
block in start_workers'"]}
sample conf:
input {
stdin { id => "inPut" }
}
filter{
ruby { code => "event['new_field'] = event.get['dummy'][1..4]" }
}
output {
stdout { codec => rubydebug }
}