Splunk Search

Search the strings that are not available in lookup file

prettysunshinez
Explorer

All,

I have a question on how to perform a search with the strings that are not available in lookup file..

I have a lookup file as below
Test_Name|Test_Case
Abar|Aliq
Azad|Aliq
And so on

Now i would want to search something like below.

Index= NOT "Abar" NOT "Azad".

How to perform for all the values in lookup file.

Thanks

Tags (1)
0 Karma

niketn
Legend

@prettysunshinez try the following search

index=<yourIndexName> 
    [| inputlookup <yourLookupFile> 
    | stats values(Test_Name) as Test_Name 
    | eval Test_Name=" NOT (\"".mvjoin(Test_Name,"\" OR \"")."\")" 
    | rename Test_Name as search]

Provided your lookup file has Test_Name field values as Abar and Azad the above query will execute a search similar to the following:

index=<yourIndexName> NOT ("Abar" OR "Azad")

Following is a run anywhere example based on Splunk's _internal index with component field where instead of lookup, I am using same index to pull fewer components using recent time and then running the main query for a longer time period to return all the components that were present for overall time but not in the recent time.

index=_internal sourcetype=splunkd log_level!=INFO earliest=-24h latest=now 
    [ search index=_internal sourcetype=splunkd log_level!=INFO earliest=-1h latest=now 
    | stats values(component) as component 
    | eval component=" NOT (\"".mvjoin(component,"\" OR \"")."\")" 
    | rename component as search] 
| stats count by component
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...