Splunk Search

How do I edit my "eval if match" syntax to evaluate complex combinations with precedence on the order of operation?

jclemons7
Path Finder

Hello all,

I have the following eval function which functions properly:

| eval my_count=if(match(lower(FieldName),"\\\filename.exe"),1,0)

But I want to evaluate a few things in the if statement and need them to have precedence on the order of operation. What I'd like to be able to say is if FieldName contains \filename.exe OR (bob AND uncle) then 1, else 0, but for the life of me, I can't get the expected results.

Any help is greatly appreciated.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Here's a run-anywhere example.

|metadata type=sources | head 1 | eval FieldName="filename.exe" | eval bob=1 | eval uncle=1 | eval my_count=if(match(lower(FieldName),"\\\filename.exe") OR (bob==1 AND uncle==1),1,0) | table FieldName bob uncle my_count
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...