Splunk Search

sum of 2 possible fields

lanilim16
Explorer

The search result looks like this
<date>, COUNT_SENT=20, SUM_AMOUNT=50000
<date>, COUNT_RECEIVED=30, SUM_AMOUNT=10000

I need to get the total for both (COUNT_SENT + COUNT_RECEIVED) by hour, but this doesn't since they're in different events

This doesn't work

<search string> | eval total = COUNT_SENT + COUNT_RECEIVED | stats sum(total) by hour

rename doesn't work too.

I manage to only sum either the COUNT_SENT or COUNT_RECEIVED separately but not combined, I need the combined though.

Tags (3)
0 Karma

bmacias84
Champion

This should work

.... | bucket _time span=1h | stats sum(COUNT_SENT) as tcs sum(COUNT_RECEIVED) as tcr by _time | eval total=tcs+tcr
0 Karma

jnussbaum_splun
Splunk Employee
Splunk Employee

try - | bucket _time span=1h | stats sum(eval(COUNT_SENT+COUNT_RECEIVED)) AS test by _time

0 Karma

woodcock
Esteemed Legend

Like this:

... | stats sum(COUNT_SENT) AS COUNT_SENT sum(COUNT_RECEIVED) AS COUNT_RECEIVED BY hour | eval total = COUNT_SENT + COUNT_RECEIVED
0 Karma
Get Updates on the Splunk Community!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...