Splunk Search

How to search any column and count if a search string is matched

mgbersales
Loves-to-Learn

I have a saved search of the following format
ServerName Metric1 Metric2 Metric3 Metric4
Server1 Error Error GREEN GREEN
Server2 Missing Error Missing Error
Server3 GREEN GREEN GREEN GREEN
Server4 Error Error Error Error

The output should show how many servers have errors and how many servers are missing
Server with Error= 3
Server Missing = 1

Tags (1)
0 Karma

vnravikumar
Champion

Hi

Check this

| makeresults 
| eval ServerName="Server1",Metric1="Error",Metric2="Error",Metric3="GREEN",Metric4="GREEN" 
| append 
    [| makeresults 
    | eval ServerName="Server2",Metric1="Missing",Metric2="Error",Metric3="Missing",Metric4="Error"] 
| eval error =case(Metric1="Error","Error",Metric2="Error","Error",Metric3="Error","Error",Metric4="Error","Error") 
| eval missing =case(Metric1="Missing","Missing",Metric2="Missing","Missing",Metric3="Missing","Missing",Metric4="Missing","Missing") 
| stats count(eval(error="Error")) as "Server with Error" count(eval(missing="Missing")) as "Server Missing" 
| transpose
0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...