<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Multiple lookups, with an OR in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-lookups-with-an-OR/m-p/326166#M97254</link>
    <description>&lt;P&gt;Thank you. Let me give this a go, and I will respond on the thread. For whatever reason, I did not see this answer. Sorry about that. &lt;/P&gt;</description>
    <pubDate>Thu, 13 Apr 2017 19:20:32 GMT</pubDate>
    <dc:creator>stakor</dc:creator>
    <dc:date>2017-04-13T19:20:32Z</dc:date>
    <item>
      <title>Multiple lookups, with an OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-lookups-with-an-OR/m-p/326164#M97252</link>
      <description>&lt;P&gt;I am looking to use lookups in an OR for a search. Roughly what I want to do is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt;
((if IP_From_BAD_IP matches destination_IP) OR (if IP_From_BAD_IP matches source_IP))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am extracting the IPs as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;main_search&amp;gt;
[|inputlookup BAD_IP.csv|table ip_address | rename ipaddress as destination_ip]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Clearly, doing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;main_search&amp;gt;
[|inputlookup BAD_IP.csv|table ip_address | rename ipaddress as destination_ip]
[|inputlookup BAD_IP.csv|table ip_address | rename ipaddress as source_ip]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Will not work, as there is an implied AND. Not sure how to extract the lists of IPs to match the source_IP and destination_IP, with an OR. Anyone have any guidance? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:38:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-lookups-with-an-OR/m-p/326164#M97252</guid>
      <dc:creator>stakor</dc:creator>
      <dc:date>2020-09-29T13:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lookups, with an OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-lookups-with-an-OR/m-p/326165#M97253</link>
      <description>&lt;P&gt;Here's one way...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;main search giving source_ip and destination_ip&amp;gt;
| join type=left destination_ip [| inputlookup BAD_IP.csv| table ip_address | rename ip_address as ip_address1 | eval destination_ip = ip_address1]
| join type=left source_ip [| inputlookup BAD_IP.csv| table ip_address | rename ip_address as ip_address2 | eval source_ip = ip_address2]
| where isnotnull(ip_address1) OR isnotnull(ip_address2) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... here's another...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;main search giving source_ip and destination_ip&amp;gt;
| search 
    [|inputlookup BAD_IP.csv 
    | eval destination_ip=ip_address 
    | eval source_ip = ip_address 
    | table source_ip destination_ip
    | format "(" "(" OR ")" OR ")" 
    ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The latter method should only be used when the csv is pretty small, since the section of code in square brackets &lt;CODE&gt;[...]&lt;/CODE&gt; expands to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;( 
  ( destination_ip="001.001.001.001" OR source_ip="001.001.001.001" ) OR 
  ( destination_ip="002.002.002.002" OR source_ip="002.002.002.002" ) OR 
   ...
 )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...and a third method, probably more efficient than the above two, but beware the record limits on &lt;CODE&gt;append&lt;/CODE&gt;...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;main search giving source_ip and destination_ip&amp;gt;
| eval ip_address = mvappend(source_ip, destination_ip)
| eval IsDetail="Yes"
| append 
    [|inputlookup BAD_IP.csv 
     | eval IsBadIP = "Yes"
     | table ip_address IsBadIP
     ]
| eventstats max(IsBadIP) as IsBadIP by ip_address
| where IsBadIP=="Yes" AND IsDetail=="Yes"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Apr 2017 17:01:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-lookups-with-an-OR/m-p/326165#M97253</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-12T17:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple lookups, with an OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-lookups-with-an-OR/m-p/326166#M97254</link>
      <description>&lt;P&gt;Thank you. Let me give this a go, and I will respond on the thread. For whatever reason, I did not see this answer. Sorry about that. &lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 19:20:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-lookups-with-an-OR/m-p/326166#M97254</guid>
      <dc:creator>stakor</dc:creator>
      <dc:date>2017-04-13T19:20:32Z</dc:date>
    </item>
  </channel>
</rss>

