Splunk Search

Calculate the average run duration for a job and display as a visualization

christinaef07
Loves-to-Learn Everything

Hi everyone! In my logs coming in, I log the duration for a job to complete, for several different jobs. Example of duration:

1:17:42   -----> this would be 1 hr, 17 minutes, 42 seconds

How can i calculate the average duration for each job?  I want something like this: 

Jobs       |.      Duration

___________________

Job 1.     |.    0:17:41

Job 2.     |.     1:41:16

Job 3.      |.    1:05:13

 

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Here's one way.  There may be others.

... | rex field=duration "(?<hr>\d+):(?<min>\d+):(?<sec>\d+)"
| eval durationSecs = (hr*3600) + (min*60) + sec
| stats avg(durationSecs) as Duration by Jobs
| fieldformat Duration = tostring(Duration, "duration")
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...