Splunk Search

How to combine same Field1 values and sum corresponding Field2 numeric values?

krb
New Member

Hello,

This is difficult to explain, however, what I am trying to do is take the following:
(field 1=Name, Field 2=Quantity)
Field 1 - 1000 different names
Field 2 - Quantity of times Field 1 is used

Result -
I would like To combine similar names in field 1 and take the field 2 results which correspond with those names and have them listed.

So example: Field 1 = names Field 2 = Quantity 00 Final results - Combined Names = Total Quantity

Blockquote

Field 1 =Name Field 2 = #

Frog Legs 20

Frog Legs 250

Frog Legs 120
Eyeballs 50
Eyeballs 20
Eyeballs 70

Results: Field 1 = Name Field 2= Total Sum

Frog Legs 390
Eyeballs 140

Blockquote

Sorry for the awful formatting

Tags (2)
0 Karma

strive
Influencer

Try this

Your base search | stats sum(Quantity) as "Total Sum" by Name

somesoni2
Revered Legend

It would be helpful if you provide the sample logs and expected output fields/format.

0 Karma

strive
Influencer

In your example you did not give time column.

Try this
Your base search | stats sum(Quantity) as "Total Sum" by _time, Name

After that you sort it in whatever order you need

0 Karma

krb
New Member

Hello, thank you for your help. I think i have that part figure'd out now thanks to your help, but i want to |sort_time and the times are not showing up. I'm thinking it's because it's grouping things together.

0 Karma
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!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...