<?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: Hashtable Functionality OR lookup Tables in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120946#M32501</link>
    <description>&lt;P&gt;&lt;DEL&gt;You can't query the lookup files, unfortunately.&lt;/DEL&gt; Mistunderstood you. As the earlier answer noted, this is exactly what lookup does. Just use &lt;CODE&gt;key AS keyfield&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I would do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval keyfield = field1."#".field2 | lookup keyvalpairs key AS keyfield OUTPUT value | where isnotnull(value)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: if you've set a default value for your lookup, you'll need to check for that instead of null.&lt;/P&gt;

&lt;P&gt;You would then filter out any events or rows that do not have keyfield, or where keyfield doesn't match a key in the lookup table.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jan 2014 15:49:50 GMT</pubDate>
    <dc:creator>laserval</dc:creator>
    <dc:date>2014-01-22T15:49:50Z</dc:date>
    <item>
      <title>Hashtable Functionality OR lookup Tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120942#M32497</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;
I have a lookup table that looks like:&lt;/P&gt;

&lt;P&gt;Key,value&lt;BR /&gt;
&lt;BR /&gt;cat1,val1&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
cat2,val2&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
cat3,val3&lt;/P&gt;

&lt;P&gt;this is in a lookup file called keyvalpairs.csv &lt;BR /&gt;&lt;BR /&gt;
i want to query the look up table to return value when a key is passed in.&lt;/P&gt;

&lt;P&gt;key is a concat of two field values in a search &lt;/P&gt;

&lt;P&gt;i want a &lt;/P&gt;&lt;H3&gt;pseudo query &lt;/H3&gt;that looks something like, &lt;P&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;sourcetype = * | eval &lt;B&gt;keyfield&lt;/B&gt; = field1."#'.field2 | lookup keyvalpairs.csv [where Key = **keyfield&lt;/EM&gt;&lt;EM&gt;]&lt;/EM&gt; OUTPUT value | &lt;/P&gt;

&lt;P&gt;so that the concat of field1 and field2 from the events is looked into the CSV and the corresponding value is printed..&lt;/P&gt;

&lt;P&gt;is this doable?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:41:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120942#M32497</guid>
      <dc:creator>daktapaal</dc:creator>
      <dc:date>2020-09-28T15:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Hashtable Functionality OR lookup Tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120943#M32498</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I do not really understand your question. looking at the syntax of the lookup command&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/Lookup"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/Lookup&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;lookup [local=&amp;lt;bool&amp;gt;] [update=&amp;lt;bool&amp;gt;] &amp;lt;lookup-table-name&amp;gt; (&amp;lt;lookup-field&amp;gt; [AS &amp;lt;local-field&amp;gt;] ) ( OUTPUT | OUTPUTNEW &amp;lt;lookup-destfield&amp;gt; [AS &amp;lt;local-destfield&amp;gt;] )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so for me, your lookup looks like: &lt;/P&gt;

&lt;P&gt;&lt;EM&gt;lookup keyvaluepairs keyfield OUTPUT value&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2014 10:26:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120943#M32498</guid>
      <dc:creator>nekb1958</dc:creator>
      <dc:date>2014-01-22T10:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Hashtable Functionality OR lookup Tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120944#M32499</link>
      <description>&lt;P&gt;i did lookup that syntax in docs.. but my query should do the following :&lt;BR /&gt;
1. search on the sourcetype: *&lt;BR /&gt;
2.create an interim variable called keyfield which has the concat of the field1 and field2&lt;BR /&gt;
3.look up into  the CSV ( it has two headings: Key and Value.) for the record, where key = keyfield variable we evaluated.&lt;BR /&gt;
4. Output the value of the record, where Key = key field.&lt;BR /&gt;
so the pseudo query, or the query i would have thought, which obviously won't work, is :sourcetype=*|eval keyfield = field1."#'.field2 | lookup kevalpairs.csv [Key=keyfield] OUTPUT val.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2014 13:15:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120944#M32499</guid>
      <dc:creator>daktapaal</dc:creator>
      <dc:date>2014-01-22T13:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Hashtable Functionality OR lookup Tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120945#M32500</link>
      <description>&lt;P&gt;i can't do your suggestion because for &lt;EM&gt;lookup keyvaluepairs keyfield OUTPUT value&lt;/EM&gt; to work, there should be a header in csv called keyfield. but csv only has key and value as header. so i was hoping , there could be a solution where i can search for a record in the csv. where key = keyfield. and return Value entry for the corresponding record&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2014 13:20:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120945#M32500</guid>
      <dc:creator>daktapaal</dc:creator>
      <dc:date>2014-01-22T13:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Hashtable Functionality OR lookup Tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120946#M32501</link>
      <description>&lt;P&gt;&lt;DEL&gt;You can't query the lookup files, unfortunately.&lt;/DEL&gt; Mistunderstood you. As the earlier answer noted, this is exactly what lookup does. Just use &lt;CODE&gt;key AS keyfield&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I would do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval keyfield = field1."#".field2 | lookup keyvalpairs key AS keyfield OUTPUT value | where isnotnull(value)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: if you've set a default value for your lookup, you'll need to check for that instead of null.&lt;/P&gt;

&lt;P&gt;You would then filter out any events or rows that do not have keyfield, or where keyfield doesn't match a key in the lookup table.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2014 15:49:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120946#M32501</guid>
      <dc:creator>laserval</dc:creator>
      <dc:date>2014-01-22T15:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Hashtable Functionality OR lookup Tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120947#M32502</link>
      <description>&lt;P&gt;This is great. Thanks for this.. although I figured that if I keep the variable name same as the name of the key, then it works straight away . Thanks again&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2014 01:57:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Hashtable-Functionality-OR-lookup-Tables/m-p/120947#M32502</guid>
      <dc:creator>daktapaal</dc:creator>
      <dc:date>2014-01-30T01:57:56Z</dc:date>
    </item>
  </channel>
</rss>

