Logstash issue

Hi , I am new to elk stack,I want to create a new field which is the difference between two dates field.
I want to do it in logstash.
The two dates field data is given.
I am using filter like this but not getting the output.

date {
            match => [ "Start Date", "ISO8601" ]
            target => "start_date"
        }
        date {
            match => [ "End Date", "ISO8601" ]
            target => "end_date"
        }
        

ruby {
      init => "require 'time'"
      code => "
        diff = event.get('start_date') - event.get('end_date')event.set('timediff') 
        "
      add_field => [ "calculated_time_difference" ]
    }

Any help would be appreciated

Thanks in advance !

  ruby {
    code => " event.set('diff', event.get('end_date').to_f - event.get('start_date').to_f )  "
  }

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