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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...