Splunk Search

How to count one field multiple times with different condition?

rj12
Loves-to-Learn Lots

Since I am new to Splunk is there is demo query for calculating this will be helpful,Basically, i want to count one field multiple times with the different condition

Tags (2)
0 Karma

adonio
Ultra Champion

lets imagine you have a field called fruit and it has 3 unique values apple,banana,mango
you can do this:
... search for your fruit field ... | stats count by fruit
you can also do this:
... search for your fruit field ... | stats count(eval(fruit="apple") as apples count(eval(fruit="banana")) as bananas count(eval(fruit="mango")) as mangos ....

read here more:
https://docs.splunk.com/Documentation/Splunk/7.3.1/Search/Usetheevalcommandandfunctions#Example_1:_U....

note, there are other ways too

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...