<?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: For loop within Lookup Table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574137#M200093</link>
    <description>&lt;P&gt;Can you expand on what you mean by iterate and what you want do during the iteration.&lt;/P&gt;&lt;P&gt;You can use&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup lookup_name&lt;/LI-CODE&gt;&lt;P&gt;to collect all the rows from the table, but I am not sure what you are trying to achieve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Nov 2021 06:33:51 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2021-11-09T06:33:51Z</dc:date>
    <item>
      <title>For loop within Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574081#M200066</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a lookup table that looks like the following:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;host&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;timestamp&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;host1&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;10:33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;host2&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;4:24&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is "iterate" through the lookup table using the host field for host, and the timestamp for the search. Does anyone have any opinions/thoughts?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 21:05:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574081#M200066</guid>
      <dc:creator>dlawler1</dc:creator>
      <dc:date>2021-11-08T21:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: For loop within Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574137#M200093</link>
      <description>&lt;P&gt;Can you expand on what you mean by iterate and what you want do during the iteration.&lt;/P&gt;&lt;P&gt;You can use&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup lookup_name&lt;/LI-CODE&gt;&lt;P&gt;to collect all the rows from the table, but I am not sure what you are trying to achieve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 06:33:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574137#M200093</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-11-09T06:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: For loop within Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574184#M200103</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Can you expand on what you mean by iterate and what you want do during the iteration.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;My plan would be to use cell one as a host, and search for the timestamp in cell two.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index sourcetype=sourcetype host=&amp;lt;from cell one&amp;gt; "&amp;lt;from cell two&amp;gt; &lt;/LI-CODE&gt;&lt;P&gt;And then repeat this, for the next row, and so on and so fourth.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In bash/shell it would be pretty easy to accomplish this using the API, but unfortunately I do not have access to the API.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 11:59:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574184#M200103</guid>
      <dc:creator>dlawler1</dc:creator>
      <dc:date>2021-11-09T11:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: For loop within Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574192#M200104</link>
      <description>&lt;P&gt;There is a solution for that but you shouldn't use it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But seriously - you can iterate over results of one search and call a subsearch for every row of the base search but it spawns a new search for every row in base search results so it's highly ineffective. And has some more limitations because of subsearch use.&lt;/P&gt;&lt;P&gt;But you might use the subsearch to generate sets of conditions for the base search.&lt;/P&gt;&lt;P&gt;If you have a subsearch returning sets of fields, they results are by default rendered as (pseudocode):&lt;/P&gt;&lt;PRE&gt;((row1field1name=row1field1value AND row1field2name=row1field2value AND ...) OR (row2field1name=row2field1value AND row2field2name=row2field2value AND ...) OR ...)&lt;/PRE&gt;&lt;P&gt;So you can just use&lt;/P&gt;&lt;PRE&gt;[ | inputlookup &amp;lt;yourlookup.csv&amp;gt; ]&lt;/PRE&gt;&lt;P&gt;to generate set of rules for your search.&lt;/P&gt;&lt;P&gt;You just have to be sure that your subsearch returns proper fields. So if your lookup contains different field names, you might want to | rename them.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 12:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574192#M200104</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-09T12:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: For loop within Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574287#M200133</link>
      <description>&lt;P&gt;So, if I understand correctly, you want to get data from an index relating to all hosts in the lookup and then get the timestamp from the lookup.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index sourcetype=sourcetype 
    [| inputlookup yourlookup.csv | fields host ]
| lookup yourlookup.csv host&lt;/LI-CODE&gt;&lt;P&gt;What this is doing&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line 1 - search your index&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line 2 - Use a subsearch to add an additional constraint on your line 1 search which is derived from all the hosts in your lookup file.&lt;/P&gt;&lt;P&gt;Line 3 - then for all the events found from the above search, lookup the host in the event from the lookup file and get the timestamp.&lt;/P&gt;&lt;P&gt;I am sure there is more to your needs than just this, but hopefully this will help you get started.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 21:02:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/For-loop-within-Lookup-Table/m-p/574287#M200133</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-11-09T21:02:33Z</dc:date>
    </item>
  </channel>
</rss>

