Splunk Search

How to sum two fields ?

aymericbrun
Explorer

Hello,

How can i sum fields to have the total in a new field ?
For example, i have a field called (BytesReceivedPerSec) and i would have the sum of this field for all the event (in realtime)

I tried accum BytesReceivedPersec AS bytesrcvdtotal but i doesn't do a total sum of all the bytes received.

Have you an idea ?

Thanks

Tags (1)
0 Karma
1 Solution

Ant1D
Motivator

Try the following search:

index=Your_Index | stats sum(BytesReceivedPerSec) AS bytes_total

View solution in original post

0 Karma

aymericbrun
Explorer

Thank you very much 🙂

It works perfectly

my search exactly :

host=hp-dev index="main"| stats sum(BytesReceivedPersec) AS octets_recus sum(BytesSentPersec) AS octets_envoyes | eval octets_recus_Mo=octets_recus / 1000000 | eval octets_envoyes_Mo=octets_envoyes / 1000000

0 Karma

Ant1D
Motivator

Glad to help 🙂

0 Karma

Ant1D
Motivator

Try the following search:

index=Your_Index | stats sum(BytesReceivedPerSec) AS bytes_total

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