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...

Happy Splunking!

soumidutta
Explorer

Thanks
I was looking for this one

0 Karma

renjith_nair
Legend

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

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...