Splunk Search

How to use make a Logic OR for lookup?

syx093
Communicator

What I am trying to do is look through src_ip and dest_ip to see if they match the list of IP Addresses that are on a lookup table (these IP are known to be bad IP Addresses). The only problem with doing this is that I can only look at one field at a time because lookup act as a LOGIC AND when comparing fields. One solution I to append a subsearch that either looks up the other dest_ip while the main search looks up the src_ip or vice versa. Only problem is that the subsearch does not work the way I intended. Is there a better approach to do this. Any help is greatly appreciated.

0 Karma

somesoni2
Revered Legend

Here are couple of options for your requirement that can be tried

  1. Lookup values as giant OR condition (assuming your lookup file has one field called 'IP') - good if no of IP in your lookup is less

    your base search giving field src_ip and dest_ip | search [| inputlookup yourIpLookup.csv | eval src_ip=IP | eval dest_ip=IP | table src_ip dest_ip | format "(" "(" "OR" "" ") OR" ")" ]

  2. Regular Lookup command (assuming your lookup file has two field IP and flag, add flag field with all values as '1')

    your base search giving field src_ip and dest_ip | lookup yourIpLookup.csv IP as src_ip OUTPUT flag as SrcIPFound | lookup yourIpLookup.csv IP as dest_ip OUTPUT flag as DestIPFound

Use the flags SrcIPFound and DestIPFound to see if the src_ip and/or dest_ip was found in lookup.

woodcock
Esteemed Legend

You can modify the logic with the format command.

0 Karma

syx093
Communicator

Sorry for being an idiot and not proof reading. What I meant is if there is a way for me to have the lookup command act as logic OR.

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 ...