Splunk Search

Inputlookup used twice in 1 search with a NOT

willadams
Contributor

I have a problem with a 2nd NOT inputlookup that doesn't work.  If I break out of the 2nd inputlookup and run this within SPL it works.  For example the following search would work

 

 

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT interest IN ("*jump*","*sheet*","*hang*","*worry*")
| table interest

 

 

 however if I then move this into a lookup it ignores the CSV file and shows  me data that I have omitted

 

 

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest]
| table interest

 

 

 

 
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try adding format to the subsearch.

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT [|inputlookup mystuff.csv | rename field1 AS interest | fields interest | format]
| table interest

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

willadams
Contributor

Apologies I have corrected the 2nd XML example (copy and paste fail).  I tried to add a | format to my subsearch but it still operates as though the NOT for the lookup doesn't exist.

 

 

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest
]
| search NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest | format]
| table interest

 

 
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Where is the XML?

Another format command may be needed.

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest | format
]
| search NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest | format]
| table interest

Or you can use a single statement

index=foo sourcetype=foosource
[| inputlookup mystuff.csv
| rename field1 AS interest
| fields interest | format
] 
NOT [|inputlookup myexcludedstuff.csv | rename field1 AS interest | fields interest | format]
| table interest

The objective is to turn each lookup table into a valid expression such as (interest="foo" OR interest="bar") and the final query becomes

index=foo sourcetype=foosource (interest="foo" OR interest="bar")
NOT (interest="baz" OR interest="bat")
| table interest

You can verify what the final query looks like in the search log.

Run each inputlookup command separately to verify the results are valid expressions.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...