Splunk Search

How to sum one field values based on other fields values

kirrusk
Communicator

i'm trying to sum one of the fields values based on the other field values.

For example

Source    Remediated      Space_id

         A               45                       156

         B                46                       199

         B               98                        233

         B                8                          233

         A                9                          156

         D                3                          148

 

So here i want to sum  the Remediated Values with the corresponding  space_id values.

if space_id is 233 then want to add 98+8.

Result should be like.

Source    Remediated      Space_id

         A                54                      156

         B                46                      199

         B               106                     233

         D                3                         148

is this possible . 

Please help me.

Labels (4)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @kirrusk ,

try something like this:

your_search
| stats sum(Remediated) AS Remediated BY Source  Space_id
|  table Source Remediated Space_id

Ciao.

Giuseppe

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

@kirrusk 

 

Can you please try this?

 

YOUR_SEARCH  | stats sum(Remediated) as Remediated by Source,Space_id

 

 

Sample Search:

 

 

| makeresults | eval _raw="Source Remediated Space_id
A 45 156
B 46 199
B 98 233
B 8 233
A 9 156
D 3 148" | multikv forceheader=1 | stats sum(Remediated) as Remediated by Source,Space_id

 

 
0 Karma

gcusello
SplunkTrust
SplunkTrust

your_search

| stats sum(Remediated) AS Remediated BY Source  Space_id

|  table Source Remediated Space_id

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @kirrusk ,

try something like this:

your_search
| stats sum(Remediated) AS Remediated BY Source  Space_id
|  table Source Remediated Space_id

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Full-Stack Security in Financial Services: AppDynamics, Cisco Secure Application, and ...

Full-Stack Security in Financial Services: AppDynamics, Cisco Secure Application, and Splunk ES Protecting a ...

It's Customer Success Time at .conf25

Hello Splunkers,   Ready for .conf25? The customer success and experience team is and can’t wait to see you ...

Pro Tips for First-Time .conf Attendees: Advice from SplunkTrust

Heading to your first .Conf? You’re in for an unforgettable ride — learning, networking, swag collecting, ...