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

---
What goes around comes around. If it helps, hit it with Karma 🙂

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

---
What goes around comes around. If it helps, hit it with Karma 🙂

Min1025
Explorer

Thank you, it works.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...