<?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 How to add a lookup table value to matching search results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274488#M82790</link>
    <description>&lt;P&gt;I'm not sure whether or not this is a unique problem, but I'm hoping someone can help even if I'm overlooking an obvious solution :-).&lt;/P&gt;

&lt;P&gt;I have a lookup table that is a domain whitelist that we allow through our proxies. For example, let's pretend a portion of this lookup table is like this (keeping in mind that some of the whitelisted domains might be sub-domains):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uri_host
--------
google.com
amazon.com
yahoo.com
answers.splunk.com
.
.
.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'm trying to figure out is if there  is a way to not only use this lookup table to search across the proxy logs, but also add a field to each resulting event called, say, "match_string" that contains the value from the lookup table that caused the event to match.&lt;/P&gt;

&lt;P&gt;For example, if in the proxy logs there are events of people browsing to "maps.google.com" and "images.google.com", those would match my whitelist due to "google.com" being there, but I want to somehow tie that back to the lookup table so that I know it shows up in the results because it matched against "google.com". The results of this might look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uri_host              match_string
--------              ------------
maps.google.com       google.com
images.google.com     google.com
mail.yahoo.com        yahoo.com
answers.splunk.com    answers.splunk.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hopefully that explains what I'm trying to do well enough, and thank you in advance to anyone who can help!&lt;/P&gt;</description>
    <pubDate>Mon, 04 Apr 2016 17:24:06 GMT</pubDate>
    <dc:creator>techusky</dc:creator>
    <dc:date>2016-04-04T17:24:06Z</dc:date>
    <item>
      <title>How to add a lookup table value to matching search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274488#M82790</link>
      <description>&lt;P&gt;I'm not sure whether or not this is a unique problem, but I'm hoping someone can help even if I'm overlooking an obvious solution :-).&lt;/P&gt;

&lt;P&gt;I have a lookup table that is a domain whitelist that we allow through our proxies. For example, let's pretend a portion of this lookup table is like this (keeping in mind that some of the whitelisted domains might be sub-domains):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uri_host
--------
google.com
amazon.com
yahoo.com
answers.splunk.com
.
.
.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'm trying to figure out is if there  is a way to not only use this lookup table to search across the proxy logs, but also add a field to each resulting event called, say, "match_string" that contains the value from the lookup table that caused the event to match.&lt;/P&gt;

&lt;P&gt;For example, if in the proxy logs there are events of people browsing to "maps.google.com" and "images.google.com", those would match my whitelist due to "google.com" being there, but I want to somehow tie that back to the lookup table so that I know it shows up in the results because it matched against "google.com". The results of this might look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uri_host              match_string
--------              ------------
maps.google.com       google.com
images.google.com     google.com
mail.yahoo.com        yahoo.com
answers.splunk.com    answers.splunk.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hopefully that explains what I'm trying to do well enough, and thank you in advance to anyone who can help!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 17:24:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274488#M82790</guid>
      <dc:creator>techusky</dc:creator>
      <dc:date>2016-04-04T17:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a lookup table value to matching search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274489#M82791</link>
      <description>&lt;P&gt;This is a good use-case for Wildcard lookup. See this similar answer for more details&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html"&gt;https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Basically, have your lookup table as this (say domainlookup.csv)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uri_host, match_string   
*google.com,google.com
*amazon.com,amazon.com
*yahoo.com,yahoo.com
*answers.splunk.com,answers.splunk.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;have your &lt;CODE&gt;transforms.conf&lt;/CODE&gt; with this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [domainlookup]
 filename = domainlookup.csv
 match_type = WILDCARD(uri_host)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you can add a lookup command to your search OR setup automatic lookup (to add the field match_string automatically to each events of yoursourcetype)&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype]
..other settings...
LOOKUP-domain= domainlookup uri_host OUTPUT match_string
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2016 19:02:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274489#M82791</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-04-04T19:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a lookup table value to matching search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274490#M82792</link>
      <description>&lt;P&gt;I think I have things set up as you have suggested, but I'm running into an issue where nothing is actually outputting for the match_string field. I have the config added to the transforms.conf file (but did not add anything into props.conf since I'm not doing an automatic lookup).&lt;/P&gt;

&lt;P&gt;Then I'm running the following search, but match_string is blank:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proxy_logs | lookup domainlookup uri_host OUTPUT match_string | table uri_host, match_string
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2016 20:50:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274490#M82792</guid>
      <dc:creator>techusky</dc:creator>
      <dc:date>2016-04-04T20:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a lookup table value to matching search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274491#M82793</link>
      <description>&lt;P&gt;I'm able to make it work with same settings in my test machine. Can you try to run following query in your instance and let me know if you see a value for the field match_string?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval uri_host="maps.google.com" | table uri_host | lookup domainlookup uri_host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2016 21:28:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274491#M82793</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-04-04T21:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a lookup table value to matching search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274492#M82794</link>
      <description>&lt;P&gt;this should work.&lt;/P&gt;

&lt;P&gt;is it possible that you don't have a field named exactly "uri_host" in your events?&lt;/P&gt;

&lt;P&gt;also, if you post your related props.conf &amp;amp; transforms.conf stanzas along with your lookup file definition &amp;amp; sample we can help with debugging a bit more.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 01:33:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274492#M82794</guid>
      <dc:creator>jmeyers_splunk</dc:creator>
      <dc:date>2016-04-05T01:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a lookup table value to matching search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274493#M82795</link>
      <description>&lt;P&gt;WOW! Sometimes it's the smallest, dumbest things that trip you up... I was in the process of typing up the relevant part of the transforms.conf as well as a sample of the lookup csv, when I realized that the lookup table had quotes around the field names, so "match_string" instead of just match_string.&lt;/P&gt;

&lt;P&gt;I fixed the lookup table and now everything works as expected. Sheesh. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:21:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274493#M82795</guid>
      <dc:creator>techusky</dc:creator>
      <dc:date>2020-09-29T09:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a lookup table value to matching search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274494#M82796</link>
      <description>&lt;P&gt;Awesome.  Thank you for posting back your results and what lead to your problem.  Those pieces of information will help somebody else in the future.  &lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 15:17:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-a-lookup-table-value-to-matching-search-results/m-p/274494#M82796</guid>
      <dc:creator>jmeyers_splunk</dc:creator>
      <dc:date>2016-04-05T15:17:46Z</dc:date>
    </item>
  </channel>
</rss>

