<?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: Retrieving events from two time windows? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82958#M21079</link>
    <description>&lt;P&gt;Do use &lt;CODE&gt;append&lt;/CODE&gt; in this type of usage. See my answer.&lt;/P&gt;</description>
    <pubDate>Sun, 17 Apr 2011 20:10:26 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2011-04-17T20:10:26Z</dc:date>
    <item>
      <title>Retrieving events from two time windows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82954#M21075</link>
      <description>&lt;P&gt;I'd like to collect events in the flash timeline from the period of 4/1 - 4/2 and 4/8 - 4/9.&lt;/P&gt;

&lt;P&gt;First, i thought this world work, but did not:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="splunktv" (earliest=4/1/2011:0:0:0 latest=4/2/2011:23:59:00) OR (earliest=4/8/2011:0:0:0 latest=4/9/2011:23:59:00)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I tried joining _raw like this (but it did not work):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="splunktv" earliest=4/1/2011:0:0:0 latest=4/2/2011:23:59:00  | join _raw [search index=splunktv earliest=4/8/2011:0:0:0 latest=4/9/2011:23:59:00]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally, this worked, but isn't there a better way? (because i'm not really setting the timerange, i'm filtering a month's timerange and this smells inefficient)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="splunktv" monthsago=1 date_year="2011" date_month="april" ( date_mday="2" OR date_mday="3" OR date_mday=9 OR date_mday=10)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Apr 2011 06:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82954#M21075</guid>
      <dc:creator>Michael_Wilde</dc:creator>
      <dc:date>2011-04-17T06:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving events from two time windows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82955#M21076</link>
      <description>&lt;P&gt;That's pretty ugly but it might not be so bad.   &lt;/P&gt;

&lt;P&gt;Note that monthsago=1 is very old syntax ;  earliest="-1mon" is the newer and it's a little more flexible. &lt;/P&gt;

&lt;P&gt;Here's an alternative using the append command to glue searches together.  &lt;/P&gt;

&lt;P&gt;HOWEVER, there are a lot of drawbacks to using append (likewise join and appendcols) and since the date_* fields are an index-time thing, your search is probably a better option than this. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="splunktv" earliest=4/1/2011:0:0:0 latest=4/2/2011:23:59:00 
| append index="splunktv" earliest=4/8/2011:0:0:0 latest=4/9/2011:23:59:00 ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Apr 2011 16:55:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82955#M21076</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-17T16:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving events from two time windows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82956#M21077</link>
      <description>&lt;P&gt;Thanks.. I use "monthsago".. cuz i'm so old skewl...   And you're right.  I should use earliest=-1mon", because really I might want to snap it to the month, and "monthsago" probably doesn't do that.. correct?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2011 17:10:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82956#M21077</guid>
      <dc:creator>Michael_Wilde</dc:creator>
      <dc:date>2011-04-17T17:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving events from two time windows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82957#M21078</link>
      <description>&lt;P&gt;Correct.  Yea the old relative language still works but it lacks a lot of flair. earliest="-1mon", earliest="-1mon@mon",  earliest="-1mon@h",  earliest="1mon@mon+2d"...&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2011 17:19:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82957#M21078</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-17T17:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving events from two time windows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82958#M21079</link>
      <description>&lt;P&gt;Do use &lt;CODE&gt;append&lt;/CODE&gt; in this type of usage. See my answer.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2011 20:10:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82958#M21079</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-04-17T20:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving events from two time windows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82959#M21080</link>
      <description>&lt;P&gt;If the time ranges are disjoint and there's a large gap between them, definitely use &lt;CODE&gt;append&lt;/CODE&gt; for each time range. Currently (version 4.2), if you have multiple time ranges specified in your search, you'll find that Splunk in fact will scan over "all time" in your indexes, which, yes, would be remarkably inefficient (if you want two disjoint weeks worth of data, but your index contains a couple of years, that's bad). Using &lt;CODE&gt;append&lt;/CODE&gt; will run each time range in a separate search, but each one will only search the limited range, so the overhead is only that of launching one search. (You do get other disadvantages, like having to remember to specify a higher &lt;CODE&gt;maxtime&lt;/CODE&gt; and &lt;CODE&gt;timeout&lt;/CODE&gt; and &lt;CODE&gt;maxout&lt;/CODE&gt; parameter if your individual subsearches might be larger.)&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2011 20:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-events-from-two-time-windows/m-p/82959#M21080</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-04-17T20:14:12Z</dc:date>
    </item>
  </channel>
</rss>

