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 App for Anomaly Detection End of Life Announcment

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...