Splunk Search

How to exclude matching results from Lookup?

mistydennis
Communicator

Hi all - I am trying to exclude matching results from a lookup and can't get it to work. I've tried multiple searches, tried what I've found in Splunk Answers, and I just can't get this to work.

Here's what I have right now:

 

| inputlookup myinputlookup1 
| search NOT 
    [ |lookup my_lookup InLookField AS LookField OUTPUT InLookField]

 


This search runs but produces no results. What am I doing wrong? 

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

If you are using a lookup as a subsearch then you use "inputlookup" rather than lookup. There are three ways to solve your problem, two with subsearches

1. Search after lookup with a subsearch

| inputlookup myinputlookup1 
| search NOT 
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

or

2. Basic Lookup 

| inputlookup myinputlookup1 
| lookup my_lookup InLookField AS LookField OUTPUT InLookField
| where isnull(InLookField)

 or

3. inputlookup with where clause using a subsearch 

| inputlookup myinputlookup1 where NOT
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

 In each subsearch case, you need to make sure that the fields returned by the subsearch are the same as the field you want to filter from the inputlookup

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

If you are using a lookup as a subsearch then you use "inputlookup" rather than lookup. There are three ways to solve your problem, two with subsearches

1. Search after lookup with a subsearch

| inputlookup myinputlookup1 
| search NOT 
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

or

2. Basic Lookup 

| inputlookup myinputlookup1 
| lookup my_lookup InLookField AS LookField OUTPUT InLookField
| where isnull(InLookField)

 or

3. inputlookup with where clause using a subsearch 

| inputlookup myinputlookup1 where NOT
    [ | inputlookup my_lookup 
      | fields my_lookup_field_matching_outer_field ]

 In each subsearch case, you need to make sure that the fields returned by the subsearch are the same as the field you want to filter from the inputlookup

Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...