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!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...