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!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...