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!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...