Splunk Search

limit to case function?

Yarsa
Path Finder

Hi this is a simple case query I ran on splunk

... | eval country=case(country="US","USA",country="CA","CA","rest")

For some reason splunk doesn't like it, is it because there is a limit to the case?

thanks for the help

Tags (2)
0 Karma
1 Solution

Ayn
Legend

You're not specifying a condition for your last term, "rest". case needs a boolean condition to be specified for each outcome it's supposed to act on. If you want a "default" kind of condition, you could specify something that you know always to be true (1=1 for instance) as the last term because case will evaluate the statements sequentially.

... | eval country=case(country="US","USA",country="CA","CA",1=1,"rest")

View solution in original post

Ayn
Legend

You're not specifying a condition for your last term, "rest". case needs a boolean condition to be specified for each outcome it's supposed to act on. If you want a "default" kind of condition, you could specify something that you know always to be true (1=1 for instance) as the last term because case will evaluate the statements sequentially.

... | eval country=case(country="US","USA",country="CA","CA",1=1,"rest")
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 ...