Splunk Search

How to calculate multiple fields total count?

Min1025
Explorer

I have following fileds, I want to calculate the total f count: (count(f1)+count(f2)+count(f3)+count(f4))=3+3+2+1=9. How can I get the total result 9?

  1. fl=1, f2=3, f3=5
  2. f1=2, f2=2
  3. f1=2, f2=3, f3=3, f4=1
Tags (2)
0 Karma
1 Solution

renjith_nair
SplunkTrust
SplunkTrust

Hi @Min1025,

If you have only these fields as output, you could try

your search|fields "f1,f2,e.t.c." |stats count(*) as *|addtotals

Reference : https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addtotals

Happy Splunking!

View solution in original post

renjith_nair
SplunkTrust
SplunkTrust

Hi @Min1025,

If you have only these fields as output, you could try

your search|fields "f1,f2,e.t.c." |stats count(*) as *|addtotals

Reference : https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addtotals

Happy Splunking!

Min1025
Explorer

Thank you, it works.

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...