Getting Data In

How to search the time difference between start and end events for each unique event ID?

kflavin
Engager

I have a log file going to Splunk which indicates the start and end of an event for VM creation. For example, in the logs I see something like this:

6/15/2015 11:00:00 <unique ID 1> Start event
... other events...
6/15/2015 11:02:00 <unique ID 1> End event
... other events...
6/15/2015 11:04:00 <unique ID 2> Start event
... other events...
6/15/2015 11:05:00 <unique ID 2> End event

I want to be able to get the time difference between the start and end event for all unique events as given by "unique id X".

Another way of saying it is, for all unique ID's, do eval(endtimestamp - starttimestamp), and print out the time difference in table form. I'm struggling to figure out how to do this through Splunk though. Can anyone point me in the right direction?

0 Karma
1 Solution

woodcock
Esteemed Legend

Like this (assuming you are already extracting Unique ID as UniqueID😞

... | stats earliest(_time) AS startTime latest(_time) AS endTime by UniqueID | eval DurationSeconds=(endTime - startTime)

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this (assuming you are already extracting Unique ID as UniqueID😞

... | stats earliest(_time) AS startTime latest(_time) AS endTime by UniqueID | eval DurationSeconds=(endTime - startTime)
0 Karma

kflavin
Engager

Thanks. I'm still trying to get the uniqueid extracted as a field, then I'll give it a try.

0 Karma

woodcock
Esteemed Legend

Try something like this:

... | rex "^\d+/\d+/\d+\s+\d+:\d+:\d+\s+(?<UniqueID>\S+)" | stats earliest(_time) AS startTime latest(_time) AS endTime by UniqueID | eval DurationSeconds=(endTime - startTime)

kflavin
Engager

Working! Thanks for your help.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Introducing ITSI 5.0: Unified Visibility and Actionable Insights

Introducing ITSI 5.0: Unified Visibility and Actionable Insights Tuesday, July 21, 2026  |  10:00AM PT / ...

Inside Splunk Agent Observability: Understanding Agent Behavior, Tokens & Costs

Inside Splunk Agent Observability:Understanding Agent Behavior, Tokens & Costs Thursday, August 06, ...

From Data to Insight: Announcing the Winners of the Splunk Dashboard Contest

Hi Splunkers, First off, thank you to everyone who participated in our very first From Data to Insight: The ...