_rubyexception when accessing 'event' array in ruby code

Hi!

I would like to get help with the code in ruby filter.

logstash version is 5.0.0 alpha4.

I am testing the code in ruby filter as below but I am getting _rubyexception.

  ruby {
    code => "
      event['newfield'] = 'test'
    "
  }

The logstash.log shows as below,

:timestamp=>"2016-08-03T15:26:47.291000+0900", :message=>"Ruby exception occurred: undefined method[]=' for 2016-08-03T06:26:46.829Z test %{message}:LogStash::Event", :level=>:error}`

I cant find the reason why ruby filter is unable to use event array.
Could someone help me out?

Logstash 5.0 uses the new event API. Try this:

event.set('newfield', 'test')

Additional reading: https://github.com/elastic/logstash/issues/5141

@magnusbaeck

Thank you !