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!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...