Splunk Search

Summing up rows

reverse
Contributor

My search result is

Date  a.log  a.log.1 a.log.2 b.log b.log.1 b.log.2
8/1       4     3        4       5      6       7
8/2       4     3        4       5      6       7
8/3       4     3        4       5      6       7
8/4       4     3        4       5      6       7

now X =a.log+ a.log.1+a.log.2
now Y =b.log+ b.log.1+b.log.2

How can I do sum for X & Y for the entire day ?

Tags (2)
0 Karma
1 Solution

mayurr98
Super Champion

Try addtotals

 ... |  addtotals a.log* | rename Total as X | addtotals b.log*  | rename Total as Y

let me know if this helps!

View solution in original post

mayurr98
Super Champion

Try addtotals

 ... |  addtotals a.log* | rename Total as X | addtotals b.log*  | rename Total as Y

let me know if this helps!

reverse
Contributor

worked like charm 🙂

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try foreach.

... | eval X=0, Y=0 | foreach a.* [eval X = X + <<FIELD>>] | foreach b.* [eval Y = Y + <<FIELD>>] | ...
---
If this reply helps you, Karma would be appreciated.

reverse
Contributor

thank you.

0 Karma

reverse
Contributor

@Vijeta please guide

0 Karma

Vijeta
Influencer

@reverse Are these fixed number of fields for a & b? I am not sure what your question is but it seems you want to some these columns for each date

your search| eval X=a.log + a.log.1 + a.log.2| eval Y=b.log+ b.log.1+b.log.2| table Date X Y
0 Karma

reverse
Contributor

" but it seems you want to some these columns for each date" - yes

0 Karma

reverse
Contributor

The problem is I have multiple rolled logs suffixed with [.] and [numbers] OR [DATE].
for example ..
a.log.65
a.log.2019-08-10 and so on ..
I want to combine all a.logs

0 Karma

Vijeta
Influencer

@reverse Please see the answers by richgalloway and mayur, that should work for you.

Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...