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.
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

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

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...