Dashboards & Visualizations

eval function help with if else statement

thaghost99
Path Finder

hi i would like some help doing an eval function where based on 3 values of fields will determine if the eval field value be either OK or BAD

 

example these are the 4 fields in total (hostname, "chassis ready", result, synchronize)

hostname= alpha        "chassis ready"=yes    result=pass   synchronize=no

hostname= beta          "chassis ready"=yes    result=pass   synchronize=yes

hostname= charlie        "chassis ready"=no   result=pass   synchronize=yes

 

i would like to do an eval for 'overallpass' where if   ("chassis ready"=yes    result=pass   synchronize=yes) will make 'overallpass' = OK and everything else will be overallpass = 'Not Okay" by hostname

 

so based on the top table, 

here is the final output.

*************************************

Hostname         overallpass

alpha                   Not Okay

bravo                   OK

charlie                 Not Okay

 

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Use this

| eval overallpass=if('chassis ready'="yes" AND result="pass" AND synchronize="yes", "OK", "Not Okay")
| stats values(overallpass) as overallpass by hostname

NB: The chassis ready must be surrounded by SINGLE quotes as eval needs to understand the space is part of the field name. The values must be double quoted.

 

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

Use this

| eval overallpass=if('chassis ready'="yes" AND result="pass" AND synchronize="yes", "OK", "Not Okay")
| stats values(overallpass) as overallpass by hostname

NB: The chassis ready must be surrounded by SINGLE quotes as eval needs to understand the space is part of the field name. The values must be double quoted.

 

Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...