Getting Data In

how to sum numbers with space in them

halperkins
New Member

I have a field called size that takes the form:
1 2 3 4

I want to find someway to evaluate size so that is sums all the numbers.
for example, eval totalsize = (size) would evaluate to 10.

basically my field size is a collection of sizes, and i want to sum it up for the total size.
stats sum is not an option, since it sums it will sum everything over every single event.I need it to sum one event at a time.

to be very specific, here is a picture of what i am going for:
http://tinypic.com/r/2pru4h0/6

how do i get totalsize?

thanks a bunch

EDIT:
ehh
i tried something like that
unfortunately my host fields arent unique
What im doing is getting file sizes from hosts at different times.
So for example, host1 could have a different number of files at each event, and i only want to get the sum at each particular event

Is there any other way?

0 Karma

lguinn2
Legend

This solution assumes that the numbers are separated by a single space, and that the host field is unique:

yoursearchhere
| eval newNums=split(size," ")
| mvexpand newNums
|  stats sum(newNums) as TotalSize by host
0 Karma
Get Updates on the Splunk Community!

Index This | What did the zero say to the eight?

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

Splunk Observability Cloud's AI Assistant in Action Series: Onboarding New Hires & ...

This is the fifth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Now Playing: Splunk Education Summer Learning Premieres

It’s premiere season, and Splunk Education is rolling out new releases you won’t want to miss. Whether you’re ...