Splunk Search

"if" condition

gitingua
Communicator

 

 

index=IndexName  
| table username ip_address_new id_new desti 
| lookup file.csv user as username OUTPUT user id_old ip_address_old
| where NOT (id_new = id_old AND ip_address_new = ip_address_old AND username = user) 

 

Can I combine "where" and "if" command together

Or do something like this

need to write something like this

if  id_new != id_old:
     | eval match_id = not match id

elif username != user:

     | eval match_user = not match user

elif ip_address_new != ip_address_old:

      | eval match_ip = not match IP address 

else:

      | eval ....

0 Karma

PickleRick
SplunkTrust
SplunkTrust

No, you cannot mix "where" and "if". They are two different things used for two different purposes.

If you want to conditionally set different fields, you need separate set of conditions for each field (you might however reference a field you just set in the previous step in the pipeline - that can simplify things a little).

Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

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