I am trying to get a time difference between two time field using ruby filter but looks like one of the timefiled is empty or nill and that is giving me error
ERROR] ruby - Ruby exception occurred: undefined method `-' for nil:NilClass
I am already converting execution_end to date format above this code.
I don't think database has this field empty.
if [next_exec_start] == "nil" or [next_exec_start] == "" or [execution_end] == "" or [execution_end] == "nil" {
mutate { update => { "next_exec_start" => 0 } }
mutate { add_field => { "next_exec_min" => 0 } }
}
else {
date { match => ["next_exec_start", "dd-MMM-yy HH:mm"]
target => "next_exec_start" }
ruby {
init => "require 'time'"
code => "event.set('next_exec_min',(event.get('next_exec_start')-event.get('execution_end'))/60.round(2))"
}
}
What am I doing wrong. I want to skip ruby operation if next_exec_start is not present. but I need that record.