Splunk Search

Large complicated search logic

howyagoin
Contributor

I've got an index with some 80 million events in it (thus far) and I want to search it for a list of some 100+ values. There's got to be a better way than a really complicated series of OR statements -- but I can't see what it is.

I'd prefer not to have to write a custom search command, but that strikes me as one option, where my blacklist or whitelist of data is in a separate file and the custom search command will either include/exclude results based on that, but, is there a better way?

I may also want to search for results which DON'T match a particular pattern from the list...

In some cases, the list may be IP addresses in CIDR format, in other cases it may be hostnames or application names.

Thoughts?

0 Karma

mw
Splunk Employee
Splunk Employee

It depends on what you're doing. Obviously, Splunk isn't able to read your mind and show you what you want, so you'll have to communicate it somehow. If there's a way to group those items by some method, that should do it, but if they're very unique and subject to your whim at the moment of search, you'll probably have to specify everything explicitly. Can you give some examples of the data and how you would imagine making this more terse?

Obviously, you can use wildcards to search, so if what you're searching for is similar it could be as simple as:

myfield=*val*

It may be possible to use a lookup:

myfield,newfield
someval,1
otherval,1
lastval,0

with a search:

... newfield=1 | ...

It's also possible to do something similar with regular expressions:

... | eval newfield=if(match(myfield, "^...$"), 1, 0)

And there's a cidrmatch() function for eval as well.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...