Splunk Search

How to use AND in an eval case function?

ibekacyril
Explorer

I need a way of using AND in the eval function case.

For Example:

...mysearch | eval Path = case(Path=="my/path" AND Action=="check", "Yours is available", Path=="your/path" AND Action=="didnotcheck", "Mine is available" )

This did not work for me, so it seems I am doing something wrong. Thanks in advance

Tags (3)
0 Karma

javiergn
Super Champion

Maybe your path contains special characters, try using match and just specifying part of your path to see if that works. If that's the case then try replacing the match with the "==" and escaping the special characters with a backslash. I would also include a default condition (1==1) in case none of the others match and also create a variable with a different name (like NewPath) to avoid overwriting your Path variable while you are still testing this and in order to see what's going on:

mysearch 
| eval NewPath = case(
    match(Path,"my path") AND Action=="check", "Yours is available",
    match(Path,"your path") AND Action=="didnotcheck", "Mine is available" 
    1 == 1, "Others"
)
0 Karma

HiroshiSatoh
Champion

How to use the AND is not wrong. Please tell me the contents of the mistake of the search results.

< search results>
Path=="my/path" AND Action=="check" : Path="Yours is available"
Path=="your/path" AND Action=="didnotcheck" : Path="Mine is available"
else :Path=NULL

Do you have field names and path match? For example,
"... Mysearch | dedup Path, Action"
What a result of?

0 Karma

ibekacyril
Explorer

I would like to capture this cases in a field so that I can pipe it to stats. That's why I used case and eval

0 Karma
Get Updates on the Splunk Community!

Transforming Financial Data into Fraud Intelligence

Every day, banks and financial companies handle millions of transactions, logins, and customer interactions ...

How to send events & findings from AWS to Splunk using Amazon EventBridge

Amazon EventBridge is a serverless service that uses events to connect application components together, making ...

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...