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
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...