I have 2 time fields Time1 and Time2. I want to get there difference but getting error "Ruby exception occurred: undefined method `-' for nil:NilClass".
Below is the code. what is wrong in it??
`
if [Time1] {
date{
match=>["Time1","dd-MM-YYYY HH:mm:ss.SSS"]
target => "Time1"
timezone => "Asia/Riyadh"
}
}
if [Time2] {
date{
match=>["Time2","dd-MM-YYYY HH:mm:ss.SSS"]
target => "Time2"
timezone => "Asia/Riyadh"
}
}
ruby {
init => "require 'time'"
code => "
subtract = event.get('Time2') - event.get('Time1')
event.set('timediff',subtract)
"
}
`