<?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 search data on multiple days, days which are determined by another search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-data-on-multiple-days-days-which-are-determined-by/m-p/426534#M122182</link>
    <description>&lt;P&gt;Hi  gibir,&lt;BR /&gt;
let me know:&lt;BR /&gt;
do you want to find the top three days and then use these dates in another search?&lt;/P&gt;

&lt;P&gt;if this is your need you could try someting like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my index 
| eval day=strftime(_time,"%Y-%m-%d")
| search [ search 
     index=potato
     | bin _time span=1d
     | stats sum(piece) AS sum_piece BY _time
     | sort -sum_piece
     | head 3
     | eval day=strftime(_time,"%Y-%m-%d")
     | fields day
     ]
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to use the same time boundaries of the subsearhc in the main search you could use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my index [ search 
     index=potato
     | bin _time span=1d
     | stats sum(piece) AS sum_piece BY _time
     | sort -sum_piece
     | head 3
     | eval day=strftime(_time,"%Y-%m-%d")
     | stats earliest(day) AS earliest latest(day) AS latest values(day) AS day
     | fields earliest latest
     ]
| eval day=strftime(_time,"%Y-%m-%d")
| search [ search 
     index=potato
     | bin _time span=1d
     | stats sum(piece) AS sum_piece BY _time
     | sort -sum_piece
     | head 3
     | eval day=strftime(_time,"%Y-%m-%d")
     | fields day
     ]
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jul 2018 14:38:07 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2018-07-04T14:38:07Z</dc:date>
    <item>
      <title>How to search data on multiple days, days which are determined by another search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-data-on-multiple-days-days-which-are-determined-by/m-p/426533#M122181</link>
      <description>&lt;P&gt;I want to determine the top n days of a time period based on a criteria and then get some statistics only on those days.&lt;BR /&gt;
Do I use a subsearch?&lt;BR /&gt;
I can write the searches for these two things separately but I cannot link them. Also I don't know how to pass specific days as parameters to my search.&lt;/P&gt;

&lt;P&gt;I have something like this for determining the days:&lt;/P&gt;

&lt;P&gt;index=potato&lt;BR /&gt;
| bin _time span=1d&lt;BR /&gt;
| stats sum(piece) AS sum_piece BY _time&lt;BR /&gt;
| sort -sum_piece&lt;BR /&gt;
| head 3&lt;/P&gt;

&lt;P&gt;How can I pass this? Or is there a simpler solution?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:19:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-data-on-multiple-days-days-which-are-determined-by/m-p/426533#M122181</guid>
      <dc:creator>gibir</dc:creator>
      <dc:date>2020-09-29T20:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to search data on multiple days, days which are determined by another search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-data-on-multiple-days-days-which-are-determined-by/m-p/426534#M122182</link>
      <description>&lt;P&gt;Hi  gibir,&lt;BR /&gt;
let me know:&lt;BR /&gt;
do you want to find the top three days and then use these dates in another search?&lt;/P&gt;

&lt;P&gt;if this is your need you could try someting like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my index 
| eval day=strftime(_time,"%Y-%m-%d")
| search [ search 
     index=potato
     | bin _time span=1d
     | stats sum(piece) AS sum_piece BY _time
     | sort -sum_piece
     | head 3
     | eval day=strftime(_time,"%Y-%m-%d")
     | fields day
     ]
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to use the same time boundaries of the subsearhc in the main search you could use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my index [ search 
     index=potato
     | bin _time span=1d
     | stats sum(piece) AS sum_piece BY _time
     | sort -sum_piece
     | head 3
     | eval day=strftime(_time,"%Y-%m-%d")
     | stats earliest(day) AS earliest latest(day) AS latest values(day) AS day
     | fields earliest latest
     ]
| eval day=strftime(_time,"%Y-%m-%d")
| search [ search 
     index=potato
     | bin _time span=1d
     | stats sum(piece) AS sum_piece BY _time
     | sort -sum_piece
     | head 3
     | eval day=strftime(_time,"%Y-%m-%d")
     | fields day
     ]
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jul 2018 14:38:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-data-on-multiple-days-days-which-are-determined-by/m-p/426534#M122182</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-07-04T14:38:07Z</dc:date>
    </item>
  </channel>
</rss>

