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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...

Index This | How many sevens are there between 1 and 100?

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