Splunk Search

Comma separated number in sum function going negative

mjones414
Contributor

in the following situation:
... | stats sum(SumofCoreSecs) as total | eval Total = tostring(total, "commas") | table Total

This works fine up until a certain length of a number, but I recently ran across a sum value that went negative:

-9,302,873,272,376

I know that there are no negative numbers in the raw data. Is this a condition of the sum function?

Tags (2)
0 Karma
1 Solution

mjones414
Contributor

I actually figured out that my problem was the length of the _raw field itself. Occasionally the data I'm pulling in has valid event-per-line events that exceed 10,000 characters, so I had to turn truncate off in the sourcetypes and it stopped chopping off my data in random places. Splunk has a default limit here of 10,000 characters. Unfortunately I lost some data in the process of learning this that can't be regenerated but I'll catch it for future iterations.

Thanks for the help!

View solution in original post

mjones414
Contributor

I actually figured out that my problem was the length of the _raw field itself. Occasionally the data I'm pulling in has valid event-per-line events that exceed 10,000 characters, so I had to turn truncate off in the sourcetypes and it stopped chopping off my data in random places. Splunk has a default limit here of 10,000 characters. Unfortunately I lost some data in the process of learning this that can't be regenerated but I'll catch it for future iterations.

Thanks for the help!

strive
Influencer

Assuming that your SumofCoreSecs doesn't contain commas, i tested the sum function with much bigger values and it worked just fine.

In case if your SumofCoreSecs contain commas then use convert function to remove commas. See this link http://answers.splunk.com/answers/36792/how-to-sum-numbers-with-commas

0 Karma

okrabbe_splunk
Splunk Employee
Splunk Employee

Does the field SumofCoreSecs have commas?

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

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

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...