<?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: Is there any option in Splunk to run a search in a loop? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450602#M127591</link>
    <description>&lt;P&gt;Hi @sunnyb147&lt;/P&gt;

&lt;P&gt;Can't exactly say why are you looking for a loop for the scenario you described. It more looks like you want to run it on a cron schedule.&lt;BR /&gt;
In case there is a gap in understanding your logic, below is a sample of how you could use a loop - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval  Feature.Flags.1 = "True", Feature.Flags.2 = "abc", Feature.Flags.3 = "" | eval HostFlags="" | foreach "Feature.Flags"* [eval HostFlags='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'] | where HostFlags!="" | table Feature.Flags*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, take a look at - &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Foreach"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Foreach&lt;/A&gt;&lt;BR /&gt;
Hope this helps. Let me know.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jun 2019 18:27:51 GMT</pubDate>
    <dc:creator>amitm05</dc:creator>
    <dc:date>2019-06-27T18:27:51Z</dc:date>
    <item>
      <title>Is there any option in Splunk to run a search in a loop?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450600#M127589</link>
      <description>&lt;P&gt;Hi All, Good morning,&lt;BR /&gt;
Is there any option in Splunk to run a search in a loop?&lt;/P&gt;

&lt;P&gt;Basically what I want to say is I have a search which is producing some result in a tabular format and further I am piping that in a CSV file, a single iteration is working fine.&lt;/P&gt;

&lt;P&gt;But I want to run that search lets say for 7 days based on date_mday, so I was wondering if there is a way like for loop kind of a thing so that every time when the search is executed it appends the output to a csv file.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Sample search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test1 country=india 
| dedup txn-id| stats count(txn-id) as unique_txns by date_mday, date_month 
| table date_mday, date_month, unique_txns
| outputlookup append=true sunny_test.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help/guidance would be really appreciated.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Sunny&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 09:40:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450600#M127589</guid>
      <dc:creator>sunnyb147</dc:creator>
      <dc:date>2019-06-27T09:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any option in Splunk to run a search in a loop?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450601#M127590</link>
      <description>&lt;P&gt;Where is the problem exactly? Create a scheduled search that runs every seven days with &lt;CODE&gt;earliest=-7d@d AND latest=@d&lt;/CODE&gt; for example and that's it. Your outputlookup already uses the option &lt;CODE&gt;append=true&lt;/CODE&gt; so the files should get appended.&lt;/P&gt;

&lt;P&gt;Skalli&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 16:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450601#M127590</guid>
      <dc:creator>skalliger</dc:creator>
      <dc:date>2019-06-27T16:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any option in Splunk to run a search in a loop?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450602#M127591</link>
      <description>&lt;P&gt;Hi @sunnyb147&lt;/P&gt;

&lt;P&gt;Can't exactly say why are you looking for a loop for the scenario you described. It more looks like you want to run it on a cron schedule.&lt;BR /&gt;
In case there is a gap in understanding your logic, below is a sample of how you could use a loop - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval  Feature.Flags.1 = "True", Feature.Flags.2 = "abc", Feature.Flags.3 = "" | eval HostFlags="" | foreach "Feature.Flags"* [eval HostFlags='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'] | where HostFlags!="" | table Feature.Flags*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, take a look at - &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Foreach"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Foreach&lt;/A&gt;&lt;BR /&gt;
Hope this helps. Let me know.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 18:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450602#M127591</guid>
      <dc:creator>amitm05</dc:creator>
      <dc:date>2019-06-27T18:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any option in Splunk to run a search in a loop?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450603#M127592</link>
      <description>&lt;P&gt;Let me know if this answers your query. Or if there is more to it yet. Please accept if you are ok with the answer. Thaks&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 08:30:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450603#M127592</guid>
      <dc:creator>amitm05</dc:creator>
      <dc:date>2019-06-28T08:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any option in Splunk to run a search in a loop?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450604#M127593</link>
      <description>&lt;P&gt;Hi @amitm05 ,&lt;/P&gt;

&lt;P&gt;Thanks for your feedback, let me try explaining the scenario, basically what I am up-to:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;If I run above query , it will give me a unique count of all transaction-ids for a specific day which I select in time-picker.&lt;/LI&gt;
&lt;LI&gt;And if I add this thing in the cron schedule, it will append the file on daily basis.&lt;/LI&gt;
&lt;LI&gt;What I want is, to have a while loop or for loop in which if I pass this query then it should take the date via date_mday field and extract the results and further append that in the csv file.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;The main issue here is if I use 7 days in time-picker and dedup the transaction-id it doesn't give me correct count reason being some transaction-ids are being duplicated over multiple dates.&lt;/P&gt;

&lt;P&gt;Example: If I search for a unique count on 30th of June 2019 the count is 515 but if I select the tenure of 7 days it gives me a count of 483 for 30th of June 2019.&lt;/P&gt;

&lt;P&gt;I tried using MAP and FOREACH but didn't got what I was looking for.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Sunny&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 07:27:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450604#M127593</guid>
      <dc:creator>sunnyb147</dc:creator>
      <dc:date>2019-07-01T07:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any option in Splunk to run a search in a loop?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450605#M127594</link>
      <description>&lt;P&gt;Hi @skalliger,&lt;/P&gt;

&lt;P&gt;Thanks for your feedback, The main issue here is if I use 7 days in time-picker or by earliest/latest and dedup the transaction-id it doesn't give me correct count reason being some transaction-ids are being duplicated over multiple dates.&lt;/P&gt;

&lt;P&gt;Example: If I search for a unique count on 30th of June 2019 the count is 515 but if I select the tenure of 7 days it gives me a count of 483 for 30th of June 2019.&lt;/P&gt;

&lt;P&gt;What I am looking for: Is to have a while loop or for loop in which if I pass this query then it should take the date via date_mday field and extract the results and further append that in the csv file.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Sunny&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 07:51:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450605#M127594</guid>
      <dc:creator>sunnyb147</dc:creator>
      <dc:date>2019-07-01T07:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any option in Splunk to run a search in a loop?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450606#M127595</link>
      <description>&lt;P&gt;Found the solution without using loop, and its working fine.&lt;/P&gt;

&lt;P&gt;Instead of doing, dedup then counting the unique transactions.. counted distinct count of transactions.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 12:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-any-option-in-Splunk-to-run-a-search-in-a-loop/m-p/450606#M127595</guid>
      <dc:creator>sunnyb147</dc:creator>
      <dc:date>2019-07-12T12:51:06Z</dc:date>
    </item>
  </channel>
</rss>

