in my log, each log line has action start time and action end time formatted as HHmmss.
I used the following code in the logstash filter.
It works well if the action lasts during the same day.
However, it runs into problems when the action end time passes midnight.
For example: this action's duration is 5 minutes
action start time 23:58:00
action end time 00:03:00 (i.e. the next day)
Then I get a wrong calculation (negative value).
I appreciate any help in solving this problem.
# get the duration of the action_time
date {
match => ["[action_start_time]", "HHmmss"]
target => "[action_start_timed]"
timezone => "America/New_York"
}
date {
match => ["[action_end_time]", "HHmmss"]
target => "[action_end_timed]"
timezone => "America/New_York"
}
ruby {
code => "event['action_duration'] = (event['action_end_timed'] - event['action_start_timed'])"
}