<?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 define a time range, filter and then apply a second time range? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143051#M29225</link>
    <description>&lt;P&gt;I need to define an outer time range, simple:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3h
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I then want to filter the results, also simple:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3h | stats count(_raw) as count by stuff | where count%2=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But now the part I am struggling with.  I want to define a time range that is even more restrictive:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3h | stats count(_raw) as count by stuff | where count%2=1 | earliest=-2h
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This syntax is invalid but hopefully describes what I am trying to achieve.  I must have the outer time range, filter and then apply a further time range, is this possible?&lt;/P&gt;</description>
    <pubDate>Sat, 27 Sep 2014 00:29:32 GMT</pubDate>
    <dc:creator>markgize</dc:creator>
    <dc:date>2014-09-27T00:29:32Z</dc:date>
    <item>
      <title>How to define a time range, filter and then apply a second time range?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143051#M29225</link>
      <description>&lt;P&gt;I need to define an outer time range, simple:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3h
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I then want to filter the results, also simple:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3h | stats count(_raw) as count by stuff | where count%2=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But now the part I am struggling with.  I want to define a time range that is even more restrictive:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3h | stats count(_raw) as count by stuff | where count%2=1 | earliest=-2h
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This syntax is invalid but hopefully describes what I am trying to achieve.  I must have the outer time range, filter and then apply a further time range, is this possible?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Sep 2014 00:29:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143051#M29225</guid>
      <dc:creator>markgize</dc:creator>
      <dc:date>2014-09-27T00:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a time range, filter and then apply a second time range?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143052#M29226</link>
      <description>&lt;P&gt;Based on the bottom search, you're trying to find events that happen in the past two hours where the count of events by &lt;CODE&gt;stuff&lt;/CODE&gt; is odd in the past three hours?&lt;/P&gt;

&lt;P&gt;If so, consider this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-3h | eventstats count by stuff | where count%2=1 AND _time &amp;gt;= relative_time(now(), "-2h")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As for your search failing, there's two things going on. First, you need a search command such as &lt;CODE&gt;where&lt;/CODE&gt; or &lt;CODE&gt;search&lt;/CODE&gt; after the last pipe. Second, at that point in the search pipeline the &lt;CODE&gt;_time&lt;/CODE&gt; field is already discarded by &lt;CODE&gt;stats&lt;/CODE&gt; so even with correct syntax you wouldn't be able to filter on time any more. &lt;CODE&gt;eventstats&lt;/CODE&gt; takes care of that by adding a &lt;CODE&gt;count&lt;/CODE&gt; field to the events without discarding anything.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Sep 2014 02:37:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143052#M29226</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-27T02:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a time range, filter and then apply a second time range?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143053#M29227</link>
      <description>&lt;P&gt;Thanks Martin you made a number of useful points:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;eventstats to retain columns&lt;/LI&gt;
&lt;LI&gt;count as the shorthand for count(_raw)&lt;/LI&gt;
&lt;LI&gt;relative_time&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The main problem I faced with my efforts was the use of stats which, as you say, meant that _time was no longer available.  I am now up and running.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 16:02:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143053#M29227</guid>
      <dc:creator>markgize</dc:creator>
      <dc:date>2014-09-29T16:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a time range, filter and then apply a second time range?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143054#M29228</link>
      <description>&lt;P&gt;For future reference, the problem I was trying to solve is the pairing up of events that are separated by a matter of minutes.  I can't use a fixed time range for this as it could split a valid pair.  Therefore, I wanted to define a broad time range and then filter out non-pairs within this range.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 16:06:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-define-a-time-range-filter-and-then-apply-a-second-time/m-p/143054#M29228</guid>
      <dc:creator>markgize</dc:creator>
      <dc:date>2014-09-29T16:06:45Z</dc:date>
    </item>
  </channel>
</rss>

