Splunk Search

Is it possible to write switch case statements in Splunk like other programming languages?

soumidutta
Explorer

Hi ,

Can it be possible to write switch case statements in Splunk like other programming languages?
If so, can you help me out with the syntax?

Tags (1)
0 Karma

renjith_nair
Legend

@soumidutta,

Yes , using eval - eval description=case(status == 200, "OK", status ==404, "Not found", status == 500, "Internal Server Error")

http://docs.splunk.com/Documentation/Splunk/7.2.0/SearchReference/ConditionalFunctions#case.28X.2C.2...

---
What goes around comes around. If it helps, hit it with Karma 🙂

soumidutta
Explorer

Thanks
I was looking for this one

0 Karma

renjith_nair
Legend

@soumidutta,
Please accept as answer if it helped you. thanks

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...

Index This | What can you do to make 55,555 equal 500?

April 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...