Splunk Search

IF alternatives

spm807
Explorer

Is there an alternative to IF(<condition>, <true>, <false>) ? I ask because I've got a couple dozen conditions to get through, and nesting all these IF statements is really awkward and ugly. I'm thinking of something like a CASE WHERE kind of command. Thanks, Splunk beginner

Labels (1)
0 Karma
1 Solution

PrewinThomas
Motivator

@spm807 

As @gcusello  mentioned, you can use case

eg:

eval status=case(
severity="high", "Critical",
severity="medium", "Warning",
severity="low", "Info",
true(), "Unknown"
)

 

Regards,
Prewin
If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!

View solution in original post

PrewinThomas
Motivator

@spm807 

As @gcusello  mentioned, you can use case

eg:

eval status=case(
severity="high", "Critical",
severity="medium", "Warning",
severity="low", "Info",
true(), "Unknown"
)

 

Regards,
Prewin
If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!

gcusello
SplunkTrust
SplunkTrust
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...