Splunk Search

Sum of duration problem

moinyuso96
Path Finder

I created some of the columns using regex. So all of the codes for the regex needs to be included. I would like to find the total duration based on StationName.

StationName          Duration

ABC123                        100

ABC123                        200

ABC456                         50

 

When I pasted this query at the end of my codes, it only shows the StationName but the sum of Duration column is empty. How can I get the sum of duration based on StationName?

| stats sum(Duration) by StationName

Labels (2)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Can you post your regex that creates Duration - it's probably because the Duration contains non numeric data and your Duration field is not a number

Try this before stats - this will make Duration a number if it has leading/trailing spaces.

| eval Duration=tonumber(trim(Duration))

 

View solution in original post

moinyuso96
Path Finder

Hi @bowesmana , thank you for your reply. This method works for me.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Can you post your regex that creates Duration - it's probably because the Duration contains non numeric data and your Duration field is not a number

Try this before stats - this will make Duration a number if it has leading/trailing spaces.

| eval Duration=tonumber(trim(Duration))

 

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...