Splunk Search

How to calculate SUM by type?

Neel881
Path Finder

Hello everyone,

I am trying to SUM the columns. 

index="nzc-neel-uttar" source="http:kyhkp"
| timechart span=1d count by Type
| eval "New_Date"=strftime(_time,"%Y-%m-%d") 
_time Type-A Type-B New_Date
20/07/2023 3 8 20/07/2023
21/07/2023 4 23

21/07/2023

22/07/2023 66 0 22/07/2023
23/07/2023 90 0 23/07/2023
24/07/2023 0 6 24/07/2023
25/07/2023 0 23 25/07/2023

 

Desired Output:

New_Date Type-A Type-B Total
20/07/2023 3 8 11
21/07/2023 4 23 27
22/07/2023 66 0 66
23/07/2023 90 0 90
24/07/2023 0 6 6
25/07/2023 0 23 23

 

Please suggest

Thanks

Labels (6)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
index="nzc-neel-uttar" source="http:kyhkp"
| timechart span=1d count by Type
| addtotals row=t
| eval "New_Date"=strftime(_time,"%Y-%m-%d") 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
index="nzc-neel-uttar" source="http:kyhkp"
| timechart span=1d count by Type
| addtotals row=t
| eval "New_Date"=strftime(_time,"%Y-%m-%d") 

Neel881
Path Finder

Its working fine, thank you so much!

How to add others columns from the index? Ex: Phase from the same index.

New_DateType-AType-BTotalPhase
20/07/202338111
21/07/2023423271
22/07/2023660661
23/07/2023900901
24/07/20230661
25/07/202302323abc

 

Also, remove and rearrange the columns sequence, mentioned in the above table.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Unless Phase can be derived from your current results, you could potentially use appendcols, but it depends on your data.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

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

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...