Splunk Search

Combine some results together into a single field label

sbrewerton
Engager

Hello

I have a query that examins events can outputs how many of each level of event there are

index=* eval level=lower(level) | stats count by level

It works fine, but in the output there are some results that should be treated/merged

levelcount
debug10
error15
fatal1
info30
information40
trace2
warn70
warning75

 

'info' and 'information' are the same thing, 'warn' and 'warning' are also the same thing

Is there any way to extend/modify this query to have the combined count for 'info' and 'information'  in a single result, and the same for 'warn' and 'warning' ? Something lik this ?

levelcount
debug10
error15
fatal1
info70
trace2
warn145

 

Many thanks

_scott

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use an eval command to normalize field values before stats.

index=* eval level=lower(level) 
| eval level=case(level="information","info", level="warning","warn", 1==1,level)
| stats count by level

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Use an eval command to normalize field values before stats.

index=* eval level=lower(level) 
| eval level=case(level="information","info", level="warning","warn", 1==1,level)
| stats count by level

 

---
If this reply helps you, Karma would be appreciated.
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...