Splunk Search

Compare timestamps

Path Finder

Is it possible to compare two times and get the difference in seconds? I have a field I am extracting called rec_time that I would like to compare to the timestamp on the event. This will show us the delay of processing the message. Both timestamps are in 24H time ..:..:..


Tags (1)
0 Karma

Re: Compare timestamps


The timestamp of the event is already available in epoch seconds in the field called _time. The next step is to convert rec_time to an epoch seconds using the eval command and strptime. Let's assume that it's formatted as: 2010-08-25T19:55:01-0700. Your search would be:

... | eval diff = _time - strptime(rec_time, "%Y-%m-%dT%H:%M:%S%z")
0 Karma