Splunk Search

Why does Alerting when timetaken for job completion exceeds averagetime?

jrb65
Engager

Trying to find Time Taken for last 7 days for a batch job using splunk search, trying to find the average of the time taken and then finding the jobs that have time taken greater than average time.

splunk search | eval sTime=strptime(StartTime, "%B %d, %Y %I:%M:%S %p") | eval eTime=strptime(EndTime, "%B %d, %Y %I:%M:%S %p") | eval TimeTaken = ceil((eTime-sTime)/60) | stats avg(TimeTaken) as avgtime by JobbName | where TimeTaken > avgtime

Once I use the stats average command, the TimeTaken values are not coming up . Tried using streamstats but averagetime calculation is not right

 

 

 

 

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

yuanliu
SplunkTrust
SplunkTrust

The command you are looking for is eventstats.

splunk search
| eval sTime=strptime(StartTime, "%B %d, %Y %I:%M:%S %p")
| eval eTime=strptime(EndTime, "%B %d, %Y %I:%M:%S %p")
| eval TimeTaken = ceil((eTime-sTime)/60)
| eventstats avg(TimeTaken) as avgtime by JobbName
| where TimeTaken > avgtime

View solution in original post

Tags (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

The command you are looking for is eventstats.

splunk search
| eval sTime=strptime(StartTime, "%B %d, %Y %I:%M:%S %p")
| eval eTime=strptime(EndTime, "%B %d, %Y %I:%M:%S %p")
| eval TimeTaken = ceil((eTime-sTime)/60)
| eventstats avg(TimeTaken) as avgtime by JobbName
| where TimeTaken > avgtime
Tags (1)
0 Karma

jrb65
Engager

Thanks yuanliu for the help.

0 Karma
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...