<?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 custom time range to sub search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489364#M194055</link>
    <description>&lt;P&gt;Hi, I want to run a search for a selected time range, and also want to do a sub search for the same duration in the previous interval. For example if user selects the last 60 mins as time range, then i want to do a sub search for the previous hour. Please help me how we can achieve this. Thanks.&lt;/P&gt;

&lt;P&gt;..my search | eval range=info_max_time - info_min_time | [search earliest=earliest from time range - range latest=latest from time range - range]&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:19:54 GMT</pubDate>
    <dc:creator>amerineni</dc:creator>
    <dc:date>2020-09-30T02:19:54Z</dc:date>
    <item>
      <title>custom time range to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489364#M194055</link>
      <description>&lt;P&gt;Hi, I want to run a search for a selected time range, and also want to do a sub search for the same duration in the previous interval. For example if user selects the last 60 mins as time range, then i want to do a sub search for the previous hour. Please help me how we can achieve this. Thanks.&lt;/P&gt;

&lt;P&gt;..my search | eval range=info_max_time - info_min_time | [search earliest=earliest from time range - range latest=latest from time range - range]&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:19:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489364#M194055</guid>
      <dc:creator>amerineni</dc:creator>
      <dc:date>2020-09-30T02:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: custom time range to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489365#M194056</link>
      <description>&lt;P&gt;For search, the sub-search is searched first. Therefore, it is possible to set the time range of the original search based on the subsearch results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*splunkd_access.log* [search earliest=-1d@d index=_internal source=*splunkd.log* ERROR | tail 1 | eval earliest=_time-60 | eval latest=_time+60 | table earliest latest | format "(" "(" "" ")" "OR" ")" ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I changed it dynamically. There are default restrictions on the subsearch results, so change them.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*splunkd_access.log* 
 [| makeresults 
  | addinfo 
  | eval latest=info_min_time
  | eval earliest=latest-(info_max_time-info_min_time)
  | table earliest latest 
  | format "(" "(" "" ")" "OR" ")" ]
| head 1
| append [search index=_internal source=*splunkd_access.log*|head 1]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Sep 2019 05:21:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489365#M194056</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2019-09-24T05:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: custom time range to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489366#M194057</link>
      <description>&lt;P&gt;the time range is not fixed here. If user selects last 60 mins, then i should compare the trend with the previous  60 mins. If user selects last 4 hours in time picker, the the subs search should compare the results with 4 hours before that time range. So the subs search time range should be calculated dynamically based on the user picked time range.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 17:22:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489366#M194057</guid>
      <dc:creator>amerineni</dc:creator>
      <dc:date>2019-09-24T17:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: custom time range to sub search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489367#M194058</link>
      <description>&lt;P&gt;Added answer.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 05:01:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/custom-time-range-to-sub-search/m-p/489367#M194058</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2019-09-25T05:01:40Z</dc:date>
    </item>
  </channel>
</rss>

