Converting old Ruby code to work with new ruby format of Logstash


(magdiel ) #1

Hi I am trying to convert a date field that I have into milliseconds. I found this old post
https://discuss.elastic.co/t/logstash-convert-date-string-to-timestamp-in-millisecond/52845

I am facing the same issue I have a date field exactly as his and I need to convert it to milli seconds his solution to do this was using the Ruby filter and doing this:

ruby {
code => "event['milli'] = 1000*Time.parse(event['[myDate]']).to_f"
}

however when I try to do it on my logstash 6.0.1 i get a Ruby error saying:
Direct event field references (i.e. event['field']) have been disabled in favor of using event get and set methods (e.g. event.get('field')). But im not sure how to change that Ruby code to work with the new logstash now. Any help would be greatly appreciated thank you!


(Magnus B├Ąck) #2

https://www.elastic.co/guide/en/logstash/current/event-api.html


(system) #3

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