Splunk Search

How to find total execution time for multiple events?

din98
Explorer

Hey all,

I have a summary table that shows these values. Each error log and log in the 'Total logs' column (which contains error logs and successful logs) have a unique timestamp.

ProcessError logsTotal logs
A510
B615
C79

 

 

I want to find the total execution time for the error logs and the total logs for each process by adding the total execution times of the error/successful logs under each process. I am hoping to get a summary table like the one shown below.

ProcessError logsTotal logsTotal execution time
A5102 minutes
B61550 seconds
C794 minutes

 

Any help would be much appreciated. Thanks!

Labels (6)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval starttime=strptime(started,"%Y-%m-%d %H:%M:%S.%7Q%:z")
| eval endtime=strptime(ended,"%Y-%m-%d %H:%M:%S.%7Q%:z")
| eval duration=endtime-starttime
| stats sum(errorLogs) as errorLogs sum(totalLogs) as totalLogs sum(duration) as duration by process
| fieldformat duration=tostring(duration, "duration")
0 Karma

din98
Explorer

Hi @ITWhisperer,

I tried that query but the 'duration' column only shows blank fields.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please try this runanywhere example to see if the functions work in your environment

| makeresults
| eval started="2022-07-25 11:35:17.3605798+00:00"
| eval ended="2022-07-25 11:48:55.4371325+00:00"
| eval starttime=strptime(started,"%Y-%m-%d %H:%M:%S.%7Q%:z")
| eval endtime=strptime(ended,"%Y-%m-%d %H:%M:%S.%7Q%:z")
| eval duration=endtime-starttime
| fieldformat duration=tostring(duration,"duration")
0 Karma

din98
Explorer

@kamlesh_vaghela

here is the sample.

 

Untitled.png

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust
@din98
Can you please share all sample events as well with the timestamp, error logs, and successful logs? This will be helpful to suggest proper solution.
KV
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 ...