<?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: Understanding the LOOKUP command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350219#M103701</link>
    <description>&lt;P&gt;Does not work whatsoever. Like everything in Splunk. &lt;/P&gt;</description>
    <pubDate>Mon, 10 Sep 2018 18:20:39 GMT</pubDate>
    <dc:creator>nick405060</dc:creator>
    <dc:date>2018-09-10T18:20:39Z</dc:date>
    <item>
      <title>Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350213#M103695</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm a bit confused with the lookup command, I.e the syntax.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;lookup &amp;lt;lookup-table-name&amp;gt; &amp;lt;lookup-field1&amp;gt; AS &amp;lt;local-field1&amp;gt;, &amp;lt;lookup-field2&amp;gt; AS &amp;lt;local-field2&amp;gt; OUTPUTNEW &amp;lt;lookup-destfield1&amp;gt; AS &amp;lt;local-destfield1&amp;gt;, &amp;lt;lookup-destfield2&amp;gt; AS &amp;lt;local-destfield2&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's my understanding of it, and hopefully someone can fill in the gaps or correct me if I've said anythign wrong.&lt;/P&gt;

&lt;P&gt;Lookups add fields from an external source to your events based on the values of fields that are already present.&lt;/P&gt;

&lt;P&gt;Now, from the syntax, I understand everything leading up to the OUTPUTNEW bit. I dont understand whats happening post OUTPUTNEW. What exactly are we doing, and why are we looking up again?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 17:58:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350213#M103695</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2017-11-02T17:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350214#M103696</link>
      <description>&lt;P&gt;you can use OUTPUT or OUTPUTNEW or neither. if neither are specified, all fields are outputted (aside from the lookup fields, since they are being matched upon)&lt;/P&gt;

&lt;P&gt;If OUTPUT is specified, only those fields are outputted and will overwrite existing fields.&lt;/P&gt;

&lt;P&gt;if OUTPUTNEW is specified, i believe it basically only brings in the lookup for events which don't already have the output fields.&lt;/P&gt;

&lt;P&gt;You aren't looking anything up again, you're basically saying &lt;STRONG&gt;lookup this field in my table to match against my events and output a copy of that field into the events&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;also, if you ever have questions or comments on the documentation, you can (and are encouraged) to submit feedback at the bottom of the page. the docs team is very responsive and helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 18:21:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350214#M103696</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-11-02T18:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350215#M103697</link>
      <description>&lt;P&gt;Here's a pretty simplistic use case. You have a lookup table called "full_user_names.csv", and it contains three columns: &lt;CODE&gt;username&lt;/CODE&gt;, &lt;CODE&gt;first_name&lt;/CODE&gt;, and &lt;CODE&gt;last_name&lt;/CODE&gt;. A sample row from this lookup table contains &lt;CODE&gt;jsmith, jane, smith&lt;/CODE&gt; - so the username &lt;CODE&gt;jsmith&lt;/CODE&gt; is mapped to a user whose full name is &lt;CODE&gt;jane smith&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You perform this search: &lt;CODE&gt;index=web_proxy&lt;/CODE&gt; and it returns events that contain &lt;CODE&gt;username=jsmith&lt;/CODE&gt;. You can use the lookup to find the user's full name:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=web_proxy | lookup full_user_names.csv username OUTPUTNEW first_name, last_name&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;After the lookup, the event will contain two new fields: &lt;CODE&gt;first_name=jane&lt;/CODE&gt; and &lt;CODE&gt;last_name=smith&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Now let's imagine you have that same lookup table, but your search returns events that contain &lt;CODE&gt;local_user=jsmith&lt;/CODE&gt; (note the field name is now &lt;CODE&gt;local_user&lt;/CODE&gt;, which doesn't match the field name &lt;CODE&gt;username&lt;/CODE&gt; in your lookup. No problem, you use the &lt;CODE&gt;AS&lt;/CODE&gt; clause to fix it:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=web_proxy | lookup full_user_names.csv username AS local_user OUTPUTNEW first_name, last_name&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Again, after the lookup, the event will contain two new fields: &lt;CODE&gt;first_name=jane&lt;/CODE&gt; and &lt;CODE&gt;last_name=smith&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;To make matters even more complicated, now you have the same lookup table, and your search returns events that contain &lt;CODE&gt;local_user=jsmith&lt;/CODE&gt;, and in order to correlate your events with some other logs, you want the user's first name to be returned into a field named &lt;CODE&gt;f_name&lt;/CODE&gt; and last name to be returned into a field named &lt;CODE&gt;l_name&lt;/CODE&gt;. Again, no problem - you solve it with the &lt;CODE&gt;AS&lt;/CODE&gt; clause again:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=web_proxy | lookup full_user_names.csv username AS local_user OUTPUTNEW first_name AS f_name, last_name AS l_name&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Now, after the lookup, the event will contain two new fields: &lt;CODE&gt;f_name=jane&lt;/CODE&gt; and &lt;CODE&gt;l_name=smith&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:33:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350215#M103697</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2020-09-29T16:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350216#M103698</link>
      <description>&lt;P&gt;Lets take an example to understand the command better.&lt;/P&gt;

&lt;P&gt;Assume there is lookup table which give STO (server type owner) and department information for a host. Say lookup table name is host_info.csv with fields host, STO, department.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host, STO,department
host1,abc,dept1
host2,xyz,dept2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, assuming you've an index which has data with src_host and dest_host and you want to add (enrich) STO and department information from host_info.csv lookup for each of src_host and dest_host. &lt;/P&gt;

&lt;P&gt;If you run this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar | table srch_host dest_host 
| lookup host_info.csv host as src_host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar | table srch_host dest_host 
| lookup host_info.csv host as src_host OUTPUT STO department
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you'll get output with following fields&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src_host,dest_host,STO,department
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since there are two hosts in your data, to avoid confusion, you would want to rename the output fields from lookup to differentiate to which host field those are associated with, so you'll do like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar | table srch_host dest_host 
| lookup host_info.csv host as src_host OUTPUT STO AS src_STO department AS src_department
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output will now have fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src_host,dest_host,src_STO,src_department
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Extending it to get information for dest host as well.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar | table srch_host dest_host 
| lookup host_info.csv host as src_host OUTPUT STO AS src_STO department AS src_department
| lookup host_info.csv host as dest_host OUTPUT STO AS dest_STO department AS dest_department
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output will now have fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src_host,dest_host,src_STO,src_department,dest_STO,dest_department
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:36:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350216#M103698</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T16:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350217#M103699</link>
      <description>&lt;P&gt;This is by far the most easy-to-digest example of using and understanding the lookup command that I've found. Thank you for taking the time to lay this out. I owe you a beer or a coffee, sir.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 22:41:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350217#M103699</guid>
      <dc:creator>danbutterman</dc:creator>
      <dc:date>2017-12-08T22:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350218#M103700</link>
      <description>&lt;P&gt;Thank you! I'm glad it's useful! &lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 22:59:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350218#M103700</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-12-08T22:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350219#M103701</link>
      <description>&lt;P&gt;Does not work whatsoever. Like everything in Splunk. &lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 18:20:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/350219#M103701</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2018-09-10T18:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding the LOOKUP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/567786#M197886</link>
      <description>&lt;P&gt;hi, do you know any data limitation if we are using "OUTPUT" in the lookup?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 07:35:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-the-LOOKUP-command/m-p/567786#M197886</guid>
      <dc:creator>amzar96</dc:creator>
      <dc:date>2021-09-21T07:35:09Z</dc:date>
    </item>
  </channel>
</rss>

