<?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: Perform lookup on static file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Perform-lookup-on-static-file/m-p/47650#M11377</link>
    <description>&lt;P&gt;I suspect the issue is the order in which splunk is performing the lookup vs field extractions.  Since you are extracting fields in your search explicitly, then you will want to use the &lt;CODE&gt;lookup&lt;/CODE&gt; command explicitly &lt;EM&gt;after&lt;/EM&gt; your fields have been extracted via the &lt;CODE&gt;rex&lt;/CODE&gt; commands.  Otherwise, I believe that splunk attempt to do automatic lookups immediately after your base search (which is simply &lt;CODE&gt;source="dns2.log"&lt;/CODE&gt;, at which point in, &lt;CODE&gt;extract_domain&lt;/CODE&gt; does not yet exist.)&lt;/P&gt;

&lt;P&gt;I would suggest you try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your existing search&amp;gt; | lookup domainstatus domain OUTPUT status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you get this working (assuming you want this to be done for other searches too) then I would suggest moving your field extractions to configuration files and then enable an automatic lookup for your source (or more preferably, for your specific sourcetype.)&lt;/P&gt;

&lt;P&gt;I'm struggling to find the exact search time operation order in the docs, or I'd link to it here.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2011 14:11:59 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2011-08-02T14:11:59Z</dc:date>
    <item>
      <title>Perform lookup on static file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Perform-lookup-on-static-file/m-p/47648#M11375</link>
      <description>&lt;P&gt;I am using the following to extract two fields at search time, extract_domain and extract_ip &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="dns2.log" 
| rex "((?&amp;lt;extract_domain&amp;gt;(\w+(\(\d\))){1,}?)$)" 
| rex mode=sed field=extract_domain "s/(\\(\\d\\))/./g" 
| rex "(?&amp;lt;extract_ip&amp;gt;\b(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\b)" 
| rex mode=sed field=extract_domain "s/.$//"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to lookup the &lt;CODE&gt;extract_domain&lt;/CODE&gt; field against a .csv file which looks something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;domain, status
splunk.com, good
facebook.com,bad
google.com, good
hi5.com, bad
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to report on all domains with a status of bad. &lt;/P&gt;

&lt;P&gt;I've followed the example for using lookup tables but it isnt working out.&lt;/P&gt;

&lt;P&gt;Please help&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:45:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Perform-lookup-on-static-file/m-p/47648#M11375</guid>
      <dc:creator>maxdessureault</dc:creator>
      <dc:date>2020-09-28T09:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Perform lookup on static file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Perform-lookup-on-static-file/m-p/47649#M11376</link>
      <description>&lt;P&gt;What isn't working out? Lookup tables would indeed be ideal to use here.&lt;/P&gt;

&lt;P&gt;Put your csv file in a "lookups" directory, for instance &lt;CODE&gt;$SPLUNK_HOME/etc/system/lookups&lt;/CODE&gt;. On the first line, put the field names you want to use, for instance "domain,status". Call the file something, say, "domainstatus.csv".&lt;/P&gt;

&lt;P&gt;Then refer to it in transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[domainstatus]
filename = domainstatus.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally refer to the lookup transform in props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::dns2.log]
LOOKUP-domainstatus = domainstatus domain OUTPUT status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After restarting Splunk you should now see a field "status" for each "domain" for the source "dns2.log".&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2011 06:19:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Perform-lookup-on-static-file/m-p/47649#M11376</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-07-25T06:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Perform lookup on static file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Perform-lookup-on-static-file/m-p/47650#M11377</link>
      <description>&lt;P&gt;I suspect the issue is the order in which splunk is performing the lookup vs field extractions.  Since you are extracting fields in your search explicitly, then you will want to use the &lt;CODE&gt;lookup&lt;/CODE&gt; command explicitly &lt;EM&gt;after&lt;/EM&gt; your fields have been extracted via the &lt;CODE&gt;rex&lt;/CODE&gt; commands.  Otherwise, I believe that splunk attempt to do automatic lookups immediately after your base search (which is simply &lt;CODE&gt;source="dns2.log"&lt;/CODE&gt;, at which point in, &lt;CODE&gt;extract_domain&lt;/CODE&gt; does not yet exist.)&lt;/P&gt;

&lt;P&gt;I would suggest you try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your existing search&amp;gt; | lookup domainstatus domain OUTPUT status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you get this working (assuming you want this to be done for other searches too) then I would suggest moving your field extractions to configuration files and then enable an automatic lookup for your source (or more preferably, for your specific sourcetype.)&lt;/P&gt;

&lt;P&gt;I'm struggling to find the exact search time operation order in the docs, or I'd link to it here.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2011 14:11:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Perform-lookup-on-static-file/m-p/47650#M11377</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2011-08-02T14:11:59Z</dc:date>
    </item>
  </channel>
</rss>

