Splunk Search

How to create an INPUTLOOKUP that matches field1 but NOT field2?

mobrienmoore1
New Member

Hello,
I am trying to perform a search against a lookup table that contains 2 columns (RDOMAIN and SDOMAIN). I would like the search to pull back all matching SDOMAINS and anything that does NOT match RDOMAIN.

sourcetype=8*| rex field=rcpt "\S+@(?;RDOMAIN;\S+)"
| rex field=from "\S+@(?;SDOMAIN;\S+)"
| search [inputlookup "MMDomains.csv" | search SDOMAIN=* | search NOT RDOMAIN ]

0 Karma

elliotproebstel
Champion

I read your requirement: "I would like the search to pull back all matching SDOMAINS and anything that does NOT match RDOMAIN" two possible ways:
1. Return all events which match SDOMAINS and all events which do not match RODMAIN
2. Return all events which match SDOMAINS and which do not match RDOMAIN

For the first:

sourcetype=8*
| rex field=rcpt "\S+@(?<RDOMAIN>\S+)" 
| rex field=from "\S+@(?<SDOMAIN>\S+)"
| search 
 [| inputlookup "MMDomains.csv" 
 | fields SDOMAIN ]
OR NOT 
 [| inputlookup "MMDomains.csv" 
 | fields RDOMAIN ]

For the second:

sourcetype=8*
| rex field=rcpt "\S+@(?<RDOMAIN>\S+)" 
| rex field=from "\S+@(?<SDOMAIN>\S+)"
| search 
 [| inputlookup "MMDomains.csv" 
 | fields SDOMAIN ]
NOT 
 [| inputlookup "MMDomains.csv" 
 | fields RDOMAIN ]
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...