Splunk Dev

'if like' help

jacqu3sy
Path Finder

Hi,

Struggling to get this to work. I'm trying to create a new field called 'severity' with specific values returned should a particular file extension be detected.

Two example values would be as follows;

bigdog.exe
bigcat.bat

With the above values then found within the field 'threat'. The logic Im trying is as follows, with the idea being that the .bat file will return a severity of high, and the .exe as low. But when trying this both come out as a low.

| eval severity=if(like(threat, "*.bat"), "high", "low")

I suspect the problem is something to do with the use of the asterix which is needed as the values change with the exception of the file extension, but cant work out how to fix. any ideas? Thanks

Tags (1)
0 Karma
1 Solution

harsmarvania57
SplunkTrust
SplunkTrust

Hi @jacqu3sy,

Please try this | eval severity=if(like(threat, "%.bat"), "high", "low") , for wildcard you need to use % instead of * with like

View solution in original post

0 Karma

jacqu3sy
Path Finder

Never mind, got it to work;

| eval severity=if(like(threat, "%.bat%"), "High", "Low")

0 Karma

harsmarvania57
SplunkTrust
SplunkTrust

Hi @jacqu3sy,

Please try this | eval severity=if(like(threat, "%.bat"), "high", "low") , for wildcard you need to use % instead of * with like

0 Karma

jacqu3sy
Path Finder

Yeah, found it in the end! Thanks for your quick reply.

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 ...