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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...