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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...