<?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 How to search based on the time range returned from subsearch ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368536#M108615</link>
    <description>&lt;P&gt;The query,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup ReleaseCalender.csv |sort Release ASC| reverse |streamstats current=f last(Production) as latest|rename Production as earliest| where Release="1"| fields earliest,latest| format "" "" "" "" "" ""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns resultset of 1 row with column names - earliest, latest, search. In which earliest and latest column values are empty  and search column value is --&amp;gt;    earliest="21/1/2017" latest="18/3/2017"&lt;/P&gt;

&lt;P&gt;I would like append the search column value to the main search so that the events between the results are returned. Below is a sample query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app | stats count |[|inputlookup ReleaseCalender.csv |sort Release ASC| reverse |streamstats current=f last(Production) as latest|rename Production as earliest| where Release="1"| fields earliest,latest| format "" "" "" "" "" ""]  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 14 Aug 2017 10:55:23 GMT</pubDate>
    <dc:creator>sangs8788</dc:creator>
    <dc:date>2017-08-14T10:55:23Z</dc:date>
    <item>
      <title>How to search based on the time range returned from subsearch ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368536#M108615</link>
      <description>&lt;P&gt;The query,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup ReleaseCalender.csv |sort Release ASC| reverse |streamstats current=f last(Production) as latest|rename Production as earliest| where Release="1"| fields earliest,latest| format "" "" "" "" "" ""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns resultset of 1 row with column names - earliest, latest, search. In which earliest and latest column values are empty  and search column value is --&amp;gt;    earliest="21/1/2017" latest="18/3/2017"&lt;/P&gt;

&lt;P&gt;I would like append the search column value to the main search so that the events between the results are returned. Below is a sample query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app | stats count |[|inputlookup ReleaseCalender.csv |sort Release ASC| reverse |streamstats current=f last(Production) as latest|rename Production as earliest| where Release="1"| fields earliest,latest| format "" "" "" "" "" ""]  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Aug 2017 10:55:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368536#M108615</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-08-14T10:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the time range returned from subsearch ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368537#M108616</link>
      <description>&lt;P&gt;TL;DR:  move the subsearch &lt;CODE&gt;[]&lt;/CODE&gt; before the first pipe &lt;CODE&gt;|&lt;/CODE&gt;. &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;The &lt;CODE&gt;format&lt;/CODE&gt; command removes the fields &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; and leaves only the field &lt;CODE&gt;search&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;search&lt;/CODE&gt; field is a special field.  When the square brackets end, whatever is in the field &lt;CODE&gt;search&lt;/CODE&gt; is returned as if the command &lt;CODE&gt;return search&lt;/CODE&gt;  or &lt;CODE&gt;return $search&lt;/CODE&gt; had been executed.   In other words, the value of &lt;CODE&gt;search&lt;/CODE&gt; in the subsearch is dropped, as-is, into the search in the place where the square brackets &lt;CODE&gt;[...]&lt;/CODE&gt;are.&lt;/P&gt;

&lt;P&gt;thus, your command after the pipe reads like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats count earliest=xxxx latest=xxxx 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;Earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; are not valid arguments for &lt;CODE&gt;stats&lt;/CODE&gt;, so you need to move them before the first pipe.  They can be valid arguments for &lt;CODE&gt;tstats&lt;/CODE&gt;, which is a generating command, but in this case, they need to be up with the implicit search before that first pipe.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 13:19:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368537#M108616</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-14T13:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the time range returned from subsearch ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368538#M108617</link>
      <description>&lt;P&gt;Not sure if &lt;CODE&gt;earliest="21/1/2017" latest="18/3/2017"&lt;/CODE&gt;will be accepted as valid time range. It'll be better to just change the value to epoch in subsearch before returning. ALso, as @Daljeanis suggested, the timerange should be specified in base search, not in stats or end of the search. Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app  [|inputlookup ReleaseCalender.csv |sort Release ASC| reverse |streamstats current=f last(Production) as latest|rename Production as earliest| where Release="1"| fields earliest,latest | convert mktime(*) timeformat="%d/%m/%Y" | format "" "" "" "" "" ""] | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Aug 2017 14:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368538#M108617</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-14T14:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the time range returned from subsearch ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368539#M108618</link>
      <description>&lt;P&gt;Is it possible to get the Release number out in order to display in the result. If i add Release field to the subsearch. There is no field in the name "Release" in the events, the query doesnt work if Release field is added to subsearch.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 13:27:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368539#M108618</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-08-15T13:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the time range returned from subsearch ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368540#M108619</link>
      <description>&lt;P&gt;Also is it possible to group the number of events by Release field, which is not part of events at all - but has the timestart and timeend for groupin ? Somthing like below result&lt;/P&gt;

&lt;P&gt;Release Count&lt;BR /&gt;
1               100&lt;BR /&gt;
2                50&lt;BR /&gt;
3                200&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 13:31:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368540#M108619</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-08-15T13:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the time range returned from subsearch ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368541#M108620</link>
      <description>&lt;P&gt;Is it possible to get the Release number out in order to display in the result. If i add Release field to the subsearch. There is no field in the name "Release" in the events, the query doesnt work if Release field is added to subsearch.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 04:56:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368541#M108620</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-08-16T04:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to search based on the time range returned from subsearch ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368542#M108621</link>
      <description>&lt;P&gt;Also is it possible to group the number of events by Release field, which is not part of events at all - but has the timestart and timeend for groupin ? Somthing like below result&lt;/P&gt;

&lt;P&gt;Release Count&lt;BR /&gt;
1 100&lt;BR /&gt;
2 50&lt;BR /&gt;
3 200&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 04:56:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-based-on-the-time-range-returned-from-subsearch/m-p/368542#M108621</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-08-16T04:56:40Z</dc:date>
    </item>
  </channel>
</rss>

