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
Legend

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
Legend

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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

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