Undefined method `each' for nil:NilClass

We are trying to flatten a json array with the following ruby code in Logstash

ruby {
  init => '@ignore = [ "@metadata", "@version" , "beat", "type", "tags"]'
  code => '
    event.get("[EventData]").each { | k, v| event.set(k, v) }
    s = ""
    event.to_hash.each { |k, v|
      unless @ignore.include?(k)
        s = s + "#{k}=\"#{v}\" "
      event.set("rawMessage", s.chomp(","))

And we get the following error:
Ruby exception occurred: undefined method `each' for nil:NilClass
Someone can help us ?

That would very much suggest that there is no EventData field on the message.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.