<?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 make subsearch use same time range, same index, same sourcetype as outer search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422626#M121359</link>
    <description>&lt;P&gt;Then how about the inverse? Does the outer search obey the limits set by the inner search? Will &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; be honoured by the outer search if they are not explicitly overridden?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2019 04:07:14 GMT</pubDate>
    <dc:creator>petenetwork</dc:creator>
    <dc:date>2019-06-14T04:07:14Z</dc:date>
    <item>
      <title>How to make subsearch use same time range, same index, same sourcetype as outer search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422624#M121357</link>
      <description>&lt;P&gt;So I specify an outer query, it usually starts like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=06/14/2019:13:00:00 latest=06/14/2019:14:00:00
index=os sourcetype=ps
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So far, so good. Now I want to find all PIDs using the same Java command line, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|search [search
  CMD=java*
  |table CMD
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then summarise the results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats values(PID) as PIDs by CMD
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The issue is that my subsearch doesn't seem to default itself to the &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; fields I specified at the very beginning of the query. In fact I have to pad my subsearch like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|search [search
  earliest=06/14/2019:13:00:00 latest=06/14/2019:14:00:00
  index=os sourcetype=ps      
  CMD=java*
  |table CMD
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is unnecessarily bulky. And I don't want to have to specify the time range multiple times.&lt;/P&gt;

&lt;P&gt;How can I make my inner search (the "subsearch") adhere to the &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; keywords specified to the outer search?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 03:15:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422624#M121357</guid>
      <dc:creator>petenetwork</dc:creator>
      <dc:date>2019-06-14T03:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to make subsearch use same time range, same index, same sourcetype as outer search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422625#M121358</link>
      <description>&lt;P&gt;No, unfortunately. An outer search cannot pass values into a subsearch. Subsearches run before the outer searches so they can't get values that aren't there to begin with.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 03:52:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422625#M121358</guid>
      <dc:creator>ragedsparrow</dc:creator>
      <dc:date>2019-06-14T03:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to make subsearch use same time range, same index, same sourcetype as outer search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422626#M121359</link>
      <description>&lt;P&gt;Then how about the inverse? Does the outer search obey the limits set by the inner search? Will &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; be honoured by the outer search if they are not explicitly overridden?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 04:07:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422626#M121359</guid>
      <dc:creator>petenetwork</dc:creator>
      <dc:date>2019-06-14T04:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to make subsearch use same time range, same index, same sourcetype as outer search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422627#M121360</link>
      <description>&lt;P&gt;It can be done.  The way it is done is kind of convoluted.  I've never used it myself, but here is a very similar example where it was successfully done:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/136791/use-a-subsearch-to-define-earliest-and-latest-for-main-search.html"&gt;https://answers.splunk.com/answers/136791/use-a-subsearch-to-define-earliest-and-latest-for-main-search.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You could use this example and build your query off of it to pass the time range from the subsearch to the outer search.  I tested the example and it does sucessfully substitute the Outer and Sub search time ranges.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 04:23:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-subsearch-use-same-time-range-same-index-same/m-p/422627#M121360</guid>
      <dc:creator>ragedsparrow</dc:creator>
      <dc:date>2019-06-14T04:23:12Z</dc:date>
    </item>
  </channel>
</rss>

