Splunk Search

Compare timestamps

ericrobinson
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 ..:..:..

Thanks!

Tags (1)
0 Karma

Stephen_Sorkin
Splunk Employee
Splunk Employee

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
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...