<?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: Can't run &amp;quot;lookup&amp;quot; on a lookup table created by &amp;quot;outputlookup&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221961#M65252</link>
    <description>&lt;P&gt;Not sure why your lookup isn't working, but you might be able to accomplish the same thing with &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;join&lt;/A&gt;.  Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{your first search} | rename src_ip as first_ip | table sid first_ip | join type=left sid [search {your second search} | table sid src_ip]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should join your two data sets together by sid&lt;/P&gt;</description>
    <pubDate>Sat, 13 Aug 2016 19:09:41 GMT</pubDate>
    <dc:creator>maciep</dc:creator>
    <dc:date>2016-08-13T19:09:41Z</dc:date>
    <item>
      <title>Can't run "lookup" on a lookup table created by "outputlookup"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221960#M65251</link>
      <description>&lt;H4&gt;About my Environment&lt;/H4&gt;

&lt;P&gt;Everything here is run using Splunk 6.4.2.&lt;/P&gt;

&lt;H4&gt;The Problem&lt;/H4&gt;

&lt;P&gt;I need to correlate session IDs and IP addresses between two sets of&lt;BR /&gt;
data. It involves:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;Finding the session IDs (sid) and source IPs (src_ip) from the first&lt;BR /&gt;
set of data.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Finding those same session IDS (sid) in the second set of data, even&lt;BR /&gt;
if they don't match the src_ip from the first set of data. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Yielding events from the second dataset with the fields sid, src_ip&lt;BR /&gt;
and first_ip, where sid is the same between both data sets, src_ip&lt;BR /&gt;
is unique to the second data set, and first_ip is the value of the&lt;BR /&gt;
sid's src_ip from the first data set.&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I've come very close to a resolution using the following pipeline:&lt;/P&gt;

&lt;P&gt;(a) pull the sid from the first set as a subsearch on the second set&lt;BR /&gt;
(b) create a sid/first_ip pairing in a lookup table "mylookup.csv"&lt;BR /&gt;
(c) perform a lookup on mylookup.csv to match sid to first_ip&lt;/P&gt;

&lt;P&gt;Here's the search I've tried:&lt;/P&gt;

&lt;P&gt;(01) {query for second set} [search {query for first set} | rename src_ip as first_ip | table sid,first_ip | outputlookup mylookup.csv | fields sid] | lookup mylookup.csv sid OUTPUT first_ip&lt;/P&gt;

&lt;P&gt;Search (01) runs fine without the "lookup" clause, in that it returns&lt;BR /&gt;
all of the events from the second data set with the same sid as those&lt;BR /&gt;
in the first. When I run the search as written, though, I get the&lt;BR /&gt;
error:&lt;/P&gt;

&lt;P&gt;(02) Error in 'lookup' command: The lookup table 'mylookup.csv' does not exist or is not available.&lt;/P&gt;

&lt;P&gt;What's strange is that I know the lookup must exist, because after&lt;BR /&gt;
running search (01), I can retrieve the table's contents using the&lt;BR /&gt;
following command [1]:&lt;/P&gt;

&lt;P&gt;(03) | inputlookup mylookup.csv&lt;/P&gt;

&lt;H4&gt;Things I've Tried&lt;/H4&gt;

&lt;P&gt;I tried using mylookup.csv to lookup sid as another field [2], like this:&lt;/P&gt;

&lt;P&gt;(05) {query} | lookup mylookup.csv sid AS my_sid.&lt;/P&gt;

&lt;P&gt;And that returned the same does not exists/not available error.&lt;/P&gt;

&lt;P&gt;I've even tried first running a search that creates mylookup.csv, then&lt;BR /&gt;
running a search to perform a lookup on mylookup.csv, like this:&lt;/P&gt;

&lt;P&gt;(04a) {query for first set} | rename src_ip as first_ip | table sid,first_ip | outputlookup mylookup.csv&lt;/P&gt;

&lt;P&gt;(04b) {query for second set} [ search {query for first set} | fields sid ] | lookup mylookup.csv sid OUTPUT first_ip&lt;/P&gt;

&lt;P&gt;Search (04a) completes, but I still get the same error at (02) when I&lt;BR /&gt;
run the search at (04b).&lt;/P&gt;

&lt;P&gt;I've checked the "Exploring Splunk" book, my Splunk training material,&lt;BR /&gt;
and answers.splunk.com and haven't found anything else explictly&lt;BR /&gt;
talking about using the lookup table created by outputlookup, just how&lt;BR /&gt;
to create the lookup table.&lt;/P&gt;

&lt;H4&gt;Questions&lt;/H4&gt;

&lt;P&gt;(A) Is there a canonical way of referencing lookups that you've&lt;BR /&gt;
    created using outputlookup that I'm missing? Do I need to create a&lt;BR /&gt;
    lookup definition for the lookup table I create, or is&lt;BR /&gt;
    mylookup.csv sufficient?&lt;/P&gt;

&lt;P&gt;(B) Is there a better way to perform the kind of correlation I want? I&lt;BR /&gt;
    haven't tried the KV Store yet, as I'd like to know that I can use&lt;BR /&gt;
    the output of outputlookup first.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;

&lt;P&gt;[1] &lt;A href="https://answers.splunk.com/answers/144139/how-do-i-search-a-csv-file-created-via-outputlookup.html" target="_blank"&gt;https://answers.splunk.com/answers/144139/how-do-i-search-a-csv-file-created-via-outputlookup.html&lt;/A&gt;&lt;BR /&gt;
[2] &lt;A href="https://answers.splunk.com/answers/54165/lookup-use-without-lookup-definition.html" target="_blank"&gt;https://answers.splunk.com/answers/54165/lookup-use-without-lookup-definition.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:34:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221960#M65251</guid>
      <dc:creator>samjenk_2</dc:creator>
      <dc:date>2020-09-29T10:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can't run "lookup" on a lookup table created by "outputlookup"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221961#M65252</link>
      <description>&lt;P&gt;Not sure why your lookup isn't working, but you might be able to accomplish the same thing with &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;join&lt;/A&gt;.  Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{your first search} | rename src_ip as first_ip | table sid first_ip | join type=left sid [search {your second search} | table sid src_ip]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should join your two data sets together by sid&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2016 19:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221961#M65252</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-08-13T19:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can't run "lookup" on a lookup table created by "outputlookup"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221962#M65253</link>
      <description>&lt;P&gt;You may be able to accomplish this without any subsearches or lookup. Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=firstset OR index=secondset) | chart values(src_ip) as ip over sid by index | where &amp;lt;&amp;lt;however you want to filter it&amp;gt;&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Aug 2016 22:33:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221962#M65253</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-13T22:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can't run "lookup" on a lookup table created by "outputlookup"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221963#M65254</link>
      <description>&lt;P&gt;Thank you, maciep, for the suggestion. This search does display the information I want as a chart, so thanks for that. &lt;/P&gt;

&lt;P&gt;I'm still chasing how to do this with a lookup table so that the first_ip field would be available for piping to stats and other summary commands. Have you been able to run queries on dynamically-generated lookups with 'outputlookup' before?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 20:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221963#M65254</guid>
      <dc:creator>samjenk_2</dc:creator>
      <dc:date>2016-08-18T20:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can't run "lookup" on a lookup table created by "outputlookup"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221964#M65255</link>
      <description>&lt;P&gt;Thanks for the suggestion, sundareshr. The query you suggest is about 3 times slower than maciep's, but I like how it rolls up all src_ip values for a given index, sort of like the list() function.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 20:16:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221964#M65255</guid>
      <dc:creator>samjenk_2</dc:creator>
      <dc:date>2016-08-18T20:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can't run "lookup" on a lookup table created by "outputlookup"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221965#M65256</link>
      <description>&lt;P&gt;hey samjenk, glad that worked.  I have been able to use a lookup table created by outputlookup.  I'm not sure I have ever tried using one from the same search where I created it, but seems like it should work.  Of course, not sure if Splunk does any optimizing behind the scenes resulting in the lookup search running before the outputlookup runs?&lt;/P&gt;

&lt;P&gt;But it looks like you tried to do them in separate searches too.  And you were able to display it with inputlookup.  So I have no idea why that wouldn't work.  When I first saw your post, I tried on my home machine (6.4.x).  And was able to successfully use the lookup command against a table I had just created with outputlookup.  &lt;/P&gt;

&lt;P&gt;I would suggest abandoning the search you're working on and see if you can just do it with a simple example.  And then troubleshoot from there.  For example, I think I used something like this to create mine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-60m | stats count by component | outputlookup test.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 01:28:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221965#M65256</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-08-19T01:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can't run "lookup" on a lookup table created by "outputlookup"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221966#M65257</link>
      <description>&lt;P&gt;Thanks again to maciep and sundareshr for their input. I've gotten a little closer on this issue, this time revisiting the notion of breaking my query into parts. I can get the behavior I want by doing the following: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(1) {query for first set} | rename src_ip as first_ip | table sid,first_ip | outputlookup mylookup.csv

(2) {query for second set} [| inputlookup mylookup.csv | fields sid] | lookup mylookup.csv sid OUTPUT first_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This approach is a variation on the one I tried in my first post, but with the subsearch based on the lookup table itself, rather than running (1) as a subsearch. This allows me to make &lt;CODE&gt;first_ip&lt;/CODE&gt; a field for every event in the second set matching on &lt;CODE&gt;sid&lt;/CODE&gt;, with which I can then treat as any other field with &lt;CODE&gt;stats&lt;/CODE&gt;, &lt;CODE&gt;timechart&lt;/CODE&gt;, and the like. It'd still be nice to be able to do this in one search, though.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 21:18:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-run-quot-lookup-quot-on-a-lookup-table-created-by-quot/m-p/221966#M65257</guid>
      <dc:creator>samjenk_2</dc:creator>
      <dc:date>2016-08-23T21:18:34Z</dc:date>
    </item>
  </channel>
</rss>

