Duration calculation failing

Hello,

I am trying to calculate duration by grog and inspirated by another topis here.
So I have this code:

  date {
    match => [ "time","UNIX_MS" ]
    target => "@timestamp"
    remove_field => [ "time" ]
  }

  mutate {
    add_field => { "[request][time]" => "%{@timestamp}" }
  }

  date {
    match => [ "[legs][0][timestamp]","UNIX_MS" ]
    target => "[response][time]"
  }

  ruby {
    code => "event['durationNew'] = Time.parse(event['[response][time]'] - event['[request][time]'])"
  }

But I am getting this error:
[2019-02-21T13:31:27,726][ERROR][logstash.filters.ruby ] Ruby exception occurred: 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')). Please consult the Logstash 5.0 breaking changes documentation for more details.

Any idea what is wrong?

Thanks and Regards, Reddy

This should be

"event.set('durationNew', Time.parse(event.get('[response][time]') - event.get('[request][time]')))"

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