Can't add a new key into hash during iteration


(Saket Kumar) #1

Getting exception while executing below ruby block:
ruby {
code => "
event.to_hash.each_pair do |k, v|
if k == 'Time_FV'
event['TimeFV']= event[k]
elsif k== 'Progess_FV'
event['ProgessFV']= event[k]
elsif k== 'Time_RV'
event['TimeRV']= event[k]
elsif k== 'Progess_RV'
event['ProgessRV']= event[k]
end
end
"
}

getting error:

Exception in filterworker {"exception"=>#<RuntimeError: can't add a new key into hash during iteration>, "backtrace"=>["org/jruby/RubyHash.java:991:in []='", "/opt/Log/logstash-1.5.0/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/util/accessors.rb:42:inset'", "/opt/Log/logstash-1.5.0/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/event.rb:146:in []='", "(ruby filter code):4:inregister'", "org/jruby/RubyHash.java:1366:in each_pair'", "(ruby filter code):2:inregister'", "org/jruby/RubyProc.java:271:in call'", "/opt/Log/logstash-1.5.0/vendor/bundle/jruby/1.9/gems/logstash-filter-ruby-0.1.5/lib/logstash/filters/ruby.rb:37:infilter'", "/opt/Log/logstash-1.5.0/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/filters/base.rb:162:in multi_filter'", "org/jruby/RubyArray.java:1613:ineach'", "/opt/Log/logstash-1.5.0/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/filters/base.rb:159:in multi_filter'", "(eval):436:infilter_func'", "/opt/Log/logstash-1.5.0/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/pipeline.rb:219:in filterworker'", "/opt/Log/logstash-1.5.0/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.0-java/lib/logstash/pipeline.rb:156:instart_filters'"], :level=>:error}

Any idea about this run time expection?


(system) #2