Getting Data In

Calculate duration of two different events

rishabhpatel20
Engager

I have logs which shows the job status ( Running, succeeded and failed) and all jobs have unique job id , now I want to calculate the duration it took to get failed or succeeded for each job id. Here, all jobs id would have two event first one -running and second - succeeded or failed.  How it can be done 

 

Splunk.PNG

Labels (1)
Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The range function should do the job.  It computes the difference between the first and last events.

index=infra_automation sourcetype=rundeck_execution
| stats range(_time) as duration, latest(status) as last_status by job_id
| sort - job_id
| eval duration = tostring(duration,"duration")
| table job_id data time last_status duration

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The range function should do the job.  It computes the difference between the first and last events.

index=infra_automation sourcetype=rundeck_execution
| stats range(_time) as duration, latest(status) as last_status by job_id
| sort - job_id
| eval duration = tostring(duration,"duration")
| table job_id data time last_status duration

 

---
If this reply helps you, Karma would be appreciated.

rishabhpatel20
Engager

Thanks a lot @richgalloway .. I was trying with other options like appendcol etc but did not go through the basic one range.. 

Thank you !

0 Karma
Get Updates on the Splunk Community!

NEW! Log Views in Splunk Observability Dashboards Gives Context From a Single Page

Today, Splunk Observability releases log views, a new feature for users to add their logs data from Splunk Log ...

Last Chance to Submit Your Paper For BSides Splunk - Deadline is August 12th!

Hello everyone! Don't wait to submit - The deadline is August 12th! We have truly missed the community so ...

Ready, Set, SOAR: How Utility Apps Can Up Level Your Playbooks!

 WATCH NOW Powering your capabilities has never been so easy with ready-made Splunk® SOAR Utility Apps. Parse ...