<?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 Lookup one column in csv against multiple extracted fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143377#M39813</link>
    <description>&lt;P&gt;I have a csv file with a blacklist of domain names and IP's. &lt;BR /&gt;
ip,domain&lt;BR /&gt;
1.1.1.1,foo.com&lt;BR /&gt;
2.2.2.2,bar.com&lt;/P&gt;

&lt;P&gt;I am trying to perform a lookup for the ip in csv against the Splunk events. In the events, there are 2 extracted fields src_ip and dest_ip that I want to check against the ip in csv. If a match is found in any of these fields, I would like to set up an alert. &lt;/P&gt;

&lt;P&gt;If I perform the following search which is looking up 1 field src_ip, it works.&lt;BR /&gt;
sourcetype=traffic_logs | dedup src_ip&lt;BR /&gt;
| lookup ipLookup ip as src_ip OUTPUT ip as match_found&lt;BR /&gt;
| where match_found!="unmatched"&lt;/P&gt;

&lt;P&gt;But for multiple fields, src_ip and dest_ip, it does not. Here is what I tried:&lt;BR /&gt;
sourcetype=traffic_logs | dedup src_ip, dest_ip&lt;BR /&gt;
| lookup ipLookup ip as src_ip, ip as dest_ip OUTPUT ip as match_found&lt;BR /&gt;
| where match_found!="unmatched"&lt;/P&gt;

&lt;P&gt;Also tried the following without success:&lt;/P&gt;

&lt;P&gt;sourcetype=traffic_logs | dedup src_ip, dest_ip&lt;BR /&gt;
| lookup ipLookup ip as src_ip OUTPUT ip as src_found&lt;BR /&gt;
| where src_found!="unmatched"&lt;BR /&gt;
| lookup ipLookup ip as dest_ip OUTPUT ip as dest_found&lt;BR /&gt;
| where dest_found!="unmatched"&lt;/P&gt;

&lt;P&gt;In the same search I would also like to look for any string that matches the value in column "domain" from the csv.&lt;/P&gt;

&lt;P&gt;Appreciate any help!&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 15:17:05 GMT</pubDate>
    <dc:creator>spj2</dc:creator>
    <dc:date>2020-09-28T15:17:05Z</dc:date>
    <item>
      <title>Lookup one column in csv against multiple extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143377#M39813</link>
      <description>&lt;P&gt;I have a csv file with a blacklist of domain names and IP's. &lt;BR /&gt;
ip,domain&lt;BR /&gt;
1.1.1.1,foo.com&lt;BR /&gt;
2.2.2.2,bar.com&lt;/P&gt;

&lt;P&gt;I am trying to perform a lookup for the ip in csv against the Splunk events. In the events, there are 2 extracted fields src_ip and dest_ip that I want to check against the ip in csv. If a match is found in any of these fields, I would like to set up an alert. &lt;/P&gt;

&lt;P&gt;If I perform the following search which is looking up 1 field src_ip, it works.&lt;BR /&gt;
sourcetype=traffic_logs | dedup src_ip&lt;BR /&gt;
| lookup ipLookup ip as src_ip OUTPUT ip as match_found&lt;BR /&gt;
| where match_found!="unmatched"&lt;/P&gt;

&lt;P&gt;But for multiple fields, src_ip and dest_ip, it does not. Here is what I tried:&lt;BR /&gt;
sourcetype=traffic_logs | dedup src_ip, dest_ip&lt;BR /&gt;
| lookup ipLookup ip as src_ip, ip as dest_ip OUTPUT ip as match_found&lt;BR /&gt;
| where match_found!="unmatched"&lt;/P&gt;

&lt;P&gt;Also tried the following without success:&lt;/P&gt;

&lt;P&gt;sourcetype=traffic_logs | dedup src_ip, dest_ip&lt;BR /&gt;
| lookup ipLookup ip as src_ip OUTPUT ip as src_found&lt;BR /&gt;
| where src_found!="unmatched"&lt;BR /&gt;
| lookup ipLookup ip as dest_ip OUTPUT ip as dest_found&lt;BR /&gt;
| where dest_found!="unmatched"&lt;/P&gt;

&lt;P&gt;In the same search I would also like to look for any string that matches the value in column "domain" from the csv.&lt;/P&gt;

&lt;P&gt;Appreciate any help!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:17:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143377#M39813</guid>
      <dc:creator>spj2</dc:creator>
      <dc:date>2020-09-28T15:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup one column in csv against multiple extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143378#M39814</link>
      <description>&lt;P&gt;Below search should help you lookup your src_ip and dest_ip in the ipLookup csv file and if anyone matches, you'll have events returned from this search so you can setup alert.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=traffic_logs | eval joinfield=1|join max=0 joinfield [|inputlookup ipLookup | fields domain | eval joinfield=1] | where LIKE(_raw,"%".domain."%")| dedup src_ip,dest_ip | lookup ipLookup ip as src_ip OUTPUT domain as src_found | lookup ipLookup ip as dest_ip OUTPUT domain as dest_found | eval shouldAlert=case(isnotnull(src_found) OR isnotnull(dest_found),"Yes",1=1,"No") | where shouldAlert="Yes"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H2&gt;Update&lt;/H2&gt;

&lt;P&gt;Try following&lt;/P&gt;

&lt;P&gt;sourcetype=traffic_logs |dedup src_ip,dest_ip| eval allIp=src_ip."#".dest_ip| eval joinfield=1|join max=0 joinfield [|inputlookup ipLookup | eval joinfield=1] | where LIKE(allIp,"%".ip."%") &lt;/P&gt;

&lt;P&gt;Explaination:&lt;BR /&gt;
First combine both IP into one field. Then cross join with lookup row [will give you Count of event * count of lookup value rows]. Then search for events where the ip from lookup file is contained in combined ip field. If any match is found, you can set your alert on that.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143378#M39814</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T15:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup one column in csv against multiple extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143379#M39815</link>
      <description>&lt;P&gt;Appreciate your response. But this did not work. At this time finding a matching IP is more important than matching the domain. I also tried without using the domain portion of the search, but did not return anything. Since I am using a test csv, I know I have common IP's in both the csv and the logs.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 14:48:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143379#M39815</guid>
      <dc:creator>spj2</dc:creator>
      <dc:date>2013-11-15T14:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup one column in csv against multiple extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143380#M39816</link>
      <description>&lt;P&gt;try the new option which I updated above.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 20:53:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-one-column-in-csv-against-multiple-extracted-fields/m-p/143380#M39816</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-11-15T20:53:33Z</dc:date>
    </item>
  </channel>
</rss>

