Splunk Search

Tabled _time - Find differences between each event

ben_leung
Builder

I have a tabled results of _time. Each one is an event and I want to find a difference for each event and have the value in another field.

index= sourcetype= | convert timeformat="%Y-%m-%d %H:%M:%S:%3N" ctime(_time) AS c_time | table c_time

c_time
======
2014-09-11 00:56:24:677
2014-09-11 00:56:24:677
2014-09-11 00:56:24:676
2014-09-11 00:56:24:676
2014-09-11 00:56:24:676
2014-09-11 00:41:24:664
2014-09-11 00:41:24:664

I want to be able to get the difference between each event and chart them by the c_time.

What is the best possible way of achieving this?

Tags (2)
1 Solution

sk314
Builder

Try using the delta command like so:

index=<index_name> sourcetype=<sourcetype_name>  | convert timeformat="%Y-%m-%d %H:%M:%S:%3N" ctime(_time) AS c_time |delta c_time as time_difference | table c_time time_difference

For more information: http://docs.splunk.com/Documentation/Splunk/6.1.3/SearchReference/Delta

View solution in original post

sk314
Builder

Try using the delta command like so:

index=<index_name> sourcetype=<sourcetype_name>  | convert timeformat="%Y-%m-%d %H:%M:%S:%3N" ctime(_time) AS c_time |delta c_time as time_difference | table c_time time_difference

For more information: http://docs.splunk.com/Documentation/Splunk/6.1.3/SearchReference/Delta

sk314
Builder

Yes. Exactly. I was too lazy to do that in my answer 😄

0 Karma

ben_leung
Builder

Thank you for the quick response, looks like I need to do more homework on this. All I have to do is convert the time_difference to a format that is human readable for users.

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...