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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Splunk Observability Metrics Cost Optimization

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...