Splunk Search

How do I sum like fields from like events and show results?

tchampagne
New Member

I have a search that extracts the events and fields that I want. I want to sum the fields in like events. Here is a sample of the data that I have:
Events | Field1 | Field2
-------------------------------------
event1 | 6 | 2
event2 | 3 | 1
event1 | 2 | 4
event2 | 1 | 2
event2 | 5 | 2
event3 | 8 | 3

I would like to end up with the following:
Events | Field1 | Field2
-------------------------------------
event1 | 8 | 6
event2 | 9 | 5
event3 | 8 | 3

Is this possible? Any clues?

Tags (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try this

<your search> | stats sum(Field1) as Sum1, sum(Field2) as Sum2 by Events | table Events Sum1 Sum2
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Try this

<your search> | stats sum(Field1) as Sum1, sum(Field2) as Sum2 by Events | table Events Sum1 Sum2
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...