Splunk Search

How to include double quotes in Switch Case

Anantha123
Communicator

Hi All,

How can I do switch case for below values
{"XXX":["ABC"]} == ABC
{"XXX":[]} == NULL .

| eval Name=case(Name == "{"XXX":[]}", "NULL", Name == "{"XXX":["ABC"]}", "ABC" ) - This is not working.

Thanks in Advance.

Tags (1)
0 Karma
1 Solution

tscroggins
Influencer

Splunk uses C-style escape sequences in strings. Escape the inner quotation marks with a backslash:

| eval Name=case(Name == "{\"XXX\":[]}", "NULL", Name == "{\"XXX\":[\"ABC\"]}", "ABC" )

View solution in original post

0 Karma

tscroggins
Influencer

Splunk uses C-style escape sequences in strings. Escape the inner quotation marks with a backslash:

| eval Name=case(Name == "{\"XXX\":[]}", "NULL", Name == "{\"XXX\":[\"ABC\"]}", "ABC" )

0 Karma

Anantha123
Communicator

Thank you. It works.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...