Splunk Search

Calculate sum of duration for Sub calls

rajkskumar
Explorer

I have data in the following structure received for every event. Some events have just one or two sub calls and some have more sub calls. I need to calculate the sum of the total duration.

 

 

 

subCalls: [ [-]
         { [-]
           completionTimeMs: 69
           method: GET
           statusCode: 200
         }
         { [-]
           completionTimeMs: 77
           method: GET
           statusCode: 200
         }
         { [-]
           completionTimeMs: 956
           method: POST
           statusCode: 200
         }
         { [-]
           completionTimeMs: 201
           method: PATCH
           statusCode: 204
         }
       ]

 

 

 

The below search calculates the sum of all the values in all the events instead of every event. Please suggest on how to proceed further.

 

 

 

mysearch
| eventstats sum(processRelevantFields.eventDetails.subCalls{}.completionTimeMs) as totalDuration
| table traceId, totalDuration

 

 

 

 

 

Labels (1)
0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...