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!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...