Splunk Search

Grouping and counting based on different values

neerajs_81
Builder

HI Team, i am caught in a maze of how to use stats function to get the data in expected format i want. 

Sample data.  We have alerts based on their different status values.  Alert and  status are field names.

Alertvalues(status)Total_Count
001_Phishing_Alert

In progress
Resolved
On-Hold

5
002_Malware_alertIn-progress
Resolved
6
003_DLP_AlertIn-Progress4



Desired / Expected output:  Want to split in based on each individual status value

AlertCountIn-ProgressResolvedOn-Hold
001_Phishing_Alert5311
002_Malware_Alert6330
003_DLP_alert4400
Total15841



I am trying using 

 

 

 

|..base search
| stats count by Alert, status
....
OR 
|..base search..
| stats count, values(status) by Alert

 

 

 

 nothing is working out to show the desired output.  Can someone pls assist? 

Labels (1)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| chart count by Alert status
| addtotals col=t fieldname=Count label=Total labelfield=Alert

View solution in original post

neerajs_81
Builder

Quick followup question, is there a way to include another field ( as in column ) as part of the final output?

For example, if i have something like below where there is another field "Priority" calculated using eval, how to include it in the final output?   As of now,  using the below query,  Priority doesn't show any data and thats expected because Priority is not part of our chart command.  I tried all different combos to add Priority in the chart command but couldn't figure out how to.

 

| eval Priorty = case(Alert like "001","P1",Alert like "002","P2")
| chart count by Alert status
| addtotals col=t fieldname=Count label=Total labelfield=Alert
| table rule_name Count status Priority

 

 

0 Karma

neerajs_81
Builder

Never mind, i figured out. Just moved the |eval statement to the end after the table command, it worked.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| chart count by Alert status
| addtotals col=t fieldname=Count label=Total labelfield=Alert

neerajs_81
Builder

Awesome. So often forget the "chart" command to use for such scenarios.   Thank you

0 Karma
Get Updates on the Splunk Community!

Application management with Targeted Application Install for Victoria Experience

  Experience a new era of flexibility in managing your Splunk Cloud Platform apps! With Targeted Application ...

Index This | What goes up and never comes down?

January 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Splunkers, Pack Your Bags: Why Cisco Live EMEA is Your Next Big Destination

The Power of Two: Splunk + Cisco at "Ludicrous Scale"   You know Splunk. You know Cisco. But have you seen ...