<?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: How to use a lookup table field to use to query another lookup table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126418#M34230</link>
    <description>&lt;P&gt;my query for the above lookups was (literally):&lt;/P&gt;

&lt;P&gt;earliest=10/01/2013:0:0:0 latest=2/2/2015:0:0:0 class=ARGUS_PASSAGE&lt;BR /&gt;&lt;BR /&gt;
[ | inputlookup area.csv | fields area_number ] &lt;BR /&gt;
[ | inputlookup visitor.csv | fields Lab_ID ]&lt;BR /&gt;&lt;BR /&gt;
| stats count by area_number, Lab_ID_id&lt;/P&gt;

&lt;P&gt;Returned 0&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:49:51 GMT</pubDate>
    <dc:creator>warrick2</dc:creator>
    <dc:date>2020-09-28T18:49:51Z</dc:date>
    <item>
      <title>How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126413#M34225</link>
      <description>&lt;P&gt;I'm a Splunk beginner, bear with me.... I am querying a system log file of access events.  I have two lookup tables defined: Visitors and Areas. Visitors table has a 6 alphanumeric userid and the Areas table has a 3 digit area number. There are 129 userids in the visitors lookup table and 50+ area_numbers in the areas table&lt;/P&gt;

&lt;P&gt;Basically I am trying to query an access log on our system to produce a report that tells me if any of the Visitors in the lookup table accessed any of the areas in the areas table, and if so, how many times they accessed any particular area. &lt;BR /&gt;
I have started with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=events sourcetype=PASSAGES 38D999 
[ | inputlookup area.csv | fields area_number ] 
| stats count by area_number
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This requires me to run the query with a manually entered visitor ID (38D999). But I can't come up with how to have the query use my Visitor lookup table to get each individual userid and run the query to get the number of accesses each user made in the areas table. Is there a query that can go sequentially through the visitor table, get the first userid, run the query against the areas table and repeat for all 129 visitors?&lt;/P&gt;

&lt;P&gt;Sample event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;30-Jan-2015 15:16:43, ARGUS_PASSAGE, NORMAL_PASSAGE, "NORMAL_PASSAGE, Station: 268, Unit Name: DOOR G, Portal: 2999, user 003835: Richard David Warrick, Badge: 2675(JO5), From Area 276, To Area 277, Biometrics: Not Configured", user 003835, badge 169739505, station 999, portal 2999, area 277, area 999, AFP 99, building 9999, badge 168234234
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Visitor.csv&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Lab ID,Name,Column1,Column12
000360,Smith,Joe E.,Smith,Joe E.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Area.csv&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;area_number
2
5
89
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:49:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126413#M34225</guid>
      <dc:creator>warrick2</dc:creator>
      <dc:date>2015-02-03T20:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126414#M34226</link>
      <description>&lt;P&gt;Could you do this ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=events sourcetype=PASSAGES 
 [ | inputlookup area.csv | fields area_number ] 
 [ | inputlookup visitor.csv | fields visitor_id ] 
 | stats count by area_number, visitor_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:56:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126414#M34226</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-02-03T20:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126415#M34227</link>
      <description>&lt;P&gt;Ran without any errors... but also ran without any results, which I know there are some of for my visitor population.  Thanks for the quick reply!  Any other ideas?  I did check both of my lookup tables for correct privileges, field names, etc.  All looked ok.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 21:22:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126415#M34227</guid>
      <dc:creator>warrick2</dc:creator>
      <dc:date>2015-02-03T21:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126416#M34228</link>
      <description>&lt;P&gt;Could you post a sample event, as well as a sample row from each lookup?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 21:43:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126416#M34228</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-02-03T21:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126417#M34229</link>
      <description>&lt;P&gt;Sure...&lt;/P&gt;

&lt;P&gt;Sample event:&lt;BR /&gt;
30-Jan-2015 15:16:43, ARGUS_PASSAGE, NORMAL_PASSAGE, "NORMAL_PASSAGE, Station: 268, Unit Name: DOOR G, Portal: 2999, user 003835: Richard David Warrick, Badge: 2675(JO5), From Area 276, To Area 277, Biometrics: Not Configured", user 003835, badge 169739505, station 999, portal 2999, area 277, area 999, AFP 99, building 9999, badge 168234234&lt;/P&gt;

&lt;P&gt;Visitor.csv&lt;BR /&gt;
Lab ID,Name,Column1,Column12&lt;BR /&gt;
000360,Smith,Joe E.,Smith,Joe E.&lt;/P&gt;

&lt;P&gt;Area.csv&lt;BR /&gt;
area_number&lt;BR /&gt;
2&lt;BR /&gt;
5&lt;BR /&gt;
89&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:49:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126417#M34229</guid>
      <dc:creator>warrick2</dc:creator>
      <dc:date>2020-09-28T18:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126418#M34230</link>
      <description>&lt;P&gt;my query for the above lookups was (literally):&lt;/P&gt;

&lt;P&gt;earliest=10/01/2013:0:0:0 latest=2/2/2015:0:0:0 class=ARGUS_PASSAGE&lt;BR /&gt;&lt;BR /&gt;
[ | inputlookup area.csv | fields area_number ] &lt;BR /&gt;
[ | inputlookup visitor.csv | fields Lab_ID ]&lt;BR /&gt;&lt;BR /&gt;
| stats count by area_number, Lab_ID_id&lt;/P&gt;

&lt;P&gt;Returned 0&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:49:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126418#M34230</guid>
      <dc:creator>warrick2</dc:creator>
      <dc:date>2020-09-28T18:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126419#M34231</link>
      <description>&lt;P&gt;Do you have your visitor ID field extracted already.&lt;/P&gt;

&lt;P&gt;If yes try this @aljohnson_splunk answer should work fine.&lt;/P&gt;

&lt;P&gt;If not, then try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=events sourcetype=PASSAGES
[ | inputlookup area.csv | fields area_number ]
[ | inputlookup visitor.csv | fields visitor_id | rename visitor_id as search  | format ]
| stats count by area_number, visitor_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Feb 2015 22:14:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126419#M34231</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-02-03T22:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126420#M34232</link>
      <description>&lt;P&gt;You could use the &lt;CODE&gt;lookup&lt;/CODE&gt; command. Note that &lt;CODE&gt;visitor.csv&lt;/CODE&gt; needs to be the name of the &lt;STRONG&gt;lookup table&lt;/STRONG&gt; file name (it may be different from the name of the file).  &lt;CODE&gt;user_id&lt;/CODE&gt; is whatever the input field for the lookup is.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=events sourcetype=PASSAGES 
 [ | inputlookup area.csv | fields area_number ] 
| lookup visitor.csv Lab_ID as user_id
| search Name=*
| stats count by area_number, user_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;by adding Name=*, you'll be filtering to events which the lookup added the name value for (only the people in the visitors.csv)&lt;/P&gt;

&lt;HR /&gt;</description>
      <pubDate>Tue, 03 Feb 2015 22:19:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126420#M34232</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-02-03T22:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a lookup table field to use to query another lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126421#M34233</link>
      <description>&lt;P&gt;I am assuming that the user ID in your sample event (e.g. 003835) is the same as the Lab_ID in Area.csv, and that the "To area" in your event is what you want to match against in Area.csv. &lt;/P&gt;

&lt;P&gt;If that's the case, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=events sourcetype=PASSAGES | rex "user\s(?&amp;lt;userid&amp;gt;\d+)," | rex "To\s\Area\s(?&amp;lt;toarea&amp;gt;\d+)," | inputlookup Visitor.csv append=t | search userid=Lab_ID | inputlookup Area.csv append=t | search toarea=area_number | stats count by area_number, Name, userid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After extracting the userid field, it appends the Visitor.csv file to your search results, then filters it to only events where the "userid" matches the "Lab ID" in your Visitors.csv table. Then, it extracts the "To Area" from your events, appends the Area.csv table, and searches for events where the "To Area" match the "area_number" in Area.csv. Then, it counts how many times each user accessed each area.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Feb 2015 13:43:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-lookup-table-field-to-use-to-query-another-lookup/m-p/126421#M34233</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-02-04T13:43:55Z</dc:date>
    </item>
  </channel>
</rss>

