Splunk Search

Search for multiple values in field

banzen
Engager

Hi,
I am trying to omit search results for a field that might have a couple of different values.
any ideas how to best do this? Is EVAL or LIKE the way to go?

Here's some sample data:
computerdisconnected="[bob sbr] [tube tue]"
computerdisconnected="[tube tue]"

condition-
If the computerdisconnected contains any values like "bob or "Tube" then don't return any results.

In other words I am getting regular reminders that these machines are disconnected, I only want NEW results so I want to keep a list of repeat offenders and ignore them.

Thanks in advance

Tags (1)
0 Karma
1 Solution

elliotproebstel
Champion

Do all the potential values for computerdisconnected get formatted like that? If so, this might work:

your base search NOT "[bob*" OR "[tube*"

So that's literally whatever you're searching for right now followed immediately by NOT "[bob*" OR "[tube*". The opening square brackets matter, I believe.

View solution in original post

elliotproebstel
Champion

Do all the potential values for computerdisconnected get formatted like that? If so, this might work:

your base search NOT "[bob*" OR "[tube*"

So that's literally whatever you're searching for right now followed immediately by NOT "[bob*" OR "[tube*". The opening square brackets matter, I believe.

banzen
Engager

And if my list continues to grow, just keep adding OR statements? OR " " OR "" OR "" ? I can do do this, just thought there was a cleaner way, like anything
LIKE or IN ("bob*,"tube*", "next*")

0 Karma

elliotproebstel
Champion

If your list is going to grow, you'd be very smart to follow @niketnilay's advice and set up a lookup table. His search structure will handle the formatting, too.

0 Karma

niketn
Legend

Agree with @elliotproebstel and to add on I would move such patterns to lookup file

<YourBaseSearch> NOT
    [| inputookup <yourLookupFileName>.csv 
     | eval <yourLookupFiledName>="*".<yourLookupFiledName>."*"
    | rename <yourLookupFiledName> as search]
| <yourRemainingSearch>

Following is a sample search based on the data that you have provided (PS: makeresults used instead of inputlookup to mock up the terms to be filtered from search.

<YourBaseSearch> NOT
    [| makeresults
    | eval lookupData="bob,tube"
    | makemv lookupData delim=","
    | mvexpand lookupData
    | eval lookupData="*".lookupData."*"
    | rename lookupData as search]
| <yourRemainingSearch>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...