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
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...