<?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 combine foreach command with lookup data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500893#M139470</link>
    <description>&lt;P&gt;Pur your 600 URLs in a lookup file called &lt;CODE&gt;uri_path.csv&lt;/CODE&gt; with a single field named &lt;CODE&gt;uri_path&lt;/CODE&gt; and then do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nginx sourcetype="nginx:plus:access"
|inputlookup append=true uri_path.csv
| stats count(eval(sourcetype="nginx:plus:access")) AS count BY uri_path
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 13 Oct 2019 08:35:08 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-10-13T08:35:08Z</dc:date>
    <item>
      <title>How to combine foreach command with lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500891#M139468</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;In order to clean our filtering rules we'd like to check if some of our old URL's are still in use (an if yes - how many times in last 90 days). Basically we'd like to perform the query below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nginx sourcetype="nginx:plus:access"
| search uri_path=&amp;lt;uri_path_we_are_searching_for&amp;gt; 
| stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is that there are almost 600 URL's we need to check.&lt;/P&gt;

&lt;P&gt;We'd like to know if there is a way to put all the URL's in a lookup and then perform a kind of  &lt;CODE&gt;foreach&lt;/CODE&gt; search.&lt;/P&gt;

&lt;P&gt;Thanks for the help.&lt;BR /&gt;
Alex.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 13:49:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500891#M139468</guid>
      <dc:creator>AlexeySh</dc:creator>
      <dc:date>2019-10-11T13:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine foreach command with lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500892#M139469</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nginx sourcetype="nginx:plus:access"  [|inputlookup your_filename|table uri_path]  
| stats count
↓
index=nginx sourcetype="nginx:plus:access" (uri_path="XXX" OR uri_path="YYY" OR uri_path="XXX")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or it can be linked using the LOOKUP command.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 15:04:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500892#M139469</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2019-10-11T15:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine foreach command with lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500893#M139470</link>
      <description>&lt;P&gt;Pur your 600 URLs in a lookup file called &lt;CODE&gt;uri_path.csv&lt;/CODE&gt; with a single field named &lt;CODE&gt;uri_path&lt;/CODE&gt; and then do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nginx sourcetype="nginx:plus:access"
|inputlookup append=true uri_path.csv
| stats count(eval(sourcetype="nginx:plus:access")) AS count BY uri_path
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Oct 2019 08:35:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500893#M139470</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-13T08:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine foreach command with lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500894#M139471</link>
      <description>&lt;P&gt;Hi @HiroshiSatoh &lt;/P&gt;

&lt;P&gt;Almost what I wanted to find. I just modified the second row in order to have a stats by each uri_path:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count by uri_path
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 09:49:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500894#M139471</guid>
      <dc:creator>AlexeySh</dc:creator>
      <dc:date>2019-10-14T09:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine foreach command with lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500895#M139472</link>
      <description>&lt;P&gt;Hi @woodcock ,&lt;/P&gt;

&lt;P&gt;Thanks for the help, but unfortunately I was not able to execute the query because of an error:&lt;BR /&gt;
&lt;CODE&gt;'Error in 'stats' command: You must specify a rename for the aggregation specifier on the dynamically evaluated field 'count(eval(sourcetype="nginx:plus:access"))'.&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 10:05:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500895#M139472</guid>
      <dc:creator>AlexeySh</dc:creator>
      <dc:date>2019-10-14T10:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine foreach command with lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500896#M139473</link>
      <description>&lt;P&gt;I edited .my answer and fixed it. Try it now.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 12:34:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-foreach-command-with-lookup-data/m-p/500896#M139473</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-14T12:34:33Z</dc:date>
    </item>
  </channel>
</rss>

