Splunk Search

Basic OR statement question

echojacques
Builder

So I have this search and it works just fine:

dest="10.*" OR dest="172.16.*" OR dest="192.168.*" AND action=failure `authentication` | table time,user,src,dest,app,action

My question is, is there a better/cleaner way to write this kind of OR statement? For example, I tried the search below and it didn't work using the pipe/OR character:

dest="10.*"|"172.16.*"|"192.168.*" AND action=failure `authentication` | table time,user,src,dest,app,action

I also tried this and it didn't work:

dest=(10.*|172.16.*|192.168.*) AND action=failure `authentication` | table time,user,src,dest,app,action

Like I said, my search at the very top works but just wondering if it's the best way to do it. Thanks!

Tags (1)
1 Solution

Ayn
Legend

Nope, that's how you would do it. If you have a long static list of destinations you could consider putting it into a lookup and then just do

[|inputlookup destinations | fields dest] AND action=failure `authentication` | table time,user,src,dest,app,action

But if this is just small lists for unique searches I'm guessing that's probably more hassle than it's worth.

View solution in original post

lukejadamec
Super Champion

Yup, your search that works is pretty much the only way to list a string of ORs.

0 Karma

Ayn
Legend

Nope, that's how you would do it. If you have a long static list of destinations you could consider putting it into a lookup and then just do

[|inputlookup destinations | fields dest] AND action=failure `authentication` | table time,user,src,dest,app,action

But if this is just small lists for unique searches I'm guessing that's probably more hassle than it's worth.

echojacques
Builder

Ok thanks for confirming my search! I have it in a dashboard panel so you're right, I'll just stick with the original version using the individual OR statements. Thanks again!

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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