<?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 Today vs. Yesterday vs. Last Week in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105295#M27303</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have a need to display a timechart which contains negative HTTP status codes (400's and 500's) today, yesterday, and same time last week.  I've used append, appendcol, stats, eval, addinfo, etc. and I can't seem to get the best fit.  Some timeout on subsearches, some don't make the _time readable and I've tried just about every example possible.&lt;/P&gt;

&lt;P&gt;I've tried to break the 3 searches into individual saved searches and build acceleration for each.  Any help would be greatly appreciated.  Here is the best performing one; that is only for today vs. yesterday which I cannot get the time series display to render nicely, but it performs the best (returning under 5 seconds).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=access_json status&amp;gt;=400 earliest=-2h@h latest=@h 
| timechart span=1m count as metric | addinfo  
| eval marker = if(_time &amp;lt; info_min_time + 3600, "Last hour", "This hour") 
| eval _time = if(_time &amp;lt; info_min_time + 3600, _time + 3600, _time) 
| chart median(metric) by _time marker
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2013 22:58:33 GMT</pubDate>
    <dc:creator>ctripod</dc:creator>
    <dc:date>2013-10-17T22:58:33Z</dc:date>
    <item>
      <title>Today vs. Yesterday vs. Last Week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105295#M27303</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have a need to display a timechart which contains negative HTTP status codes (400's and 500's) today, yesterday, and same time last week.  I've used append, appendcol, stats, eval, addinfo, etc. and I can't seem to get the best fit.  Some timeout on subsearches, some don't make the _time readable and I've tried just about every example possible.&lt;/P&gt;

&lt;P&gt;I've tried to break the 3 searches into individual saved searches and build acceleration for each.  Any help would be greatly appreciated.  Here is the best performing one; that is only for today vs. yesterday which I cannot get the time series display to render nicely, but it performs the best (returning under 5 seconds).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=access_json status&amp;gt;=400 earliest=-2h@h latest=@h 
| timechart span=1m count as metric | addinfo  
| eval marker = if(_time &amp;lt; info_min_time + 3600, "Last hour", "This hour") 
| eval _time = if(_time &amp;lt; info_min_time + 3600, _time + 3600, _time) 
| chart median(metric) by _time marker
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2013 22:58:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105295#M27303</guid>
      <dc:creator>ctripod</dc:creator>
      <dc:date>2013-10-17T22:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Today vs. Yesterday vs. Last Week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105296#M27304</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=access_json status&amp;gt;=400 earliest=-7d@d latest=@h 
| eval startToday = relative_time(now(),"-24h@h")
| eval startYesterday = relative_time(now(),"-48h@h")
| eval endLastWeek = relative_time(now(),"-168h@h")
| eval marker = case(_time &amp;gt;= startToday, "Today",
                     _time &amp;gt;=startYesterday,"Yesterday",
                     _time &amp;lt;= endLastWeek,"Last Week",
                     1=1,"Outside Range")
| where marker != "Outside Range"
| eval _time = case(marker="Today",_time,
                    marker="Yesterday",_time+86400,
                    marker="Last Week",_time+(7*86400) )
| timechart fixedrange=f count by marker
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I might be a bit off on the time math, but you get the idea. BTW, &lt;CODE&gt;now()&lt;/CODE&gt; is the time that the search started; you don't have to use &lt;CODE&gt;addinfo&lt;/CODE&gt; to get it...&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2013 23:41:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105296#M27304</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-10-17T23:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Today vs. Yesterday vs. Last Week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105297#M27305</link>
      <description>&lt;P&gt;I changed a couple of things to get the query to do exactly as desired: endLastWeek using 168h (i.e. 7 x 24) and earliest=-192h. &lt;BR /&gt;
The latter got around the unsightly issue of an extra bar due to changing from Summer to Wintertime last weekend. Took me a while to figure where that rogue bar came from.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2013 23:33:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105297#M27305</guid>
      <dc:creator>tpflicke</dc:creator>
      <dc:date>2013-11-01T23:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Today vs. Yesterday vs. Last Week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105298#M27306</link>
      <description>&lt;P&gt;index=access_json status&amp;gt;=400 earliest=-192h@h latest=@h &lt;BR /&gt;
| eval startToday = relative_time(now(),"-24h@h")&lt;BR /&gt;
| eval startYesterday = relative_time(now(),"-48h@h") &lt;BR /&gt;
| eval endLastWeek = relative_time(now(),"-168h@h")&lt;BR /&gt;
| eval marker = case(_time &amp;gt;= startToday, "Today",&lt;BR /&gt;
         _time &amp;gt;=startYesterday,"Yesterday",&lt;BR /&gt;
         _time &amp;lt;= endLastWeek,"Last Week",&lt;BR /&gt;
         1=1,"Outside Range")&lt;BR /&gt;
| where marker != "Outside Range"&lt;BR /&gt;
| eval _time = case(marker="Today",_time,&lt;BR /&gt;
         marker="Yesterday",_time+86400,&lt;BR /&gt;
         marker="Last Week",_time+(7*86400) )&lt;BR /&gt;
| timechart span=1h fixedrange=f count by marker&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:11:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105298#M27306</guid>
      <dc:creator>tpflicke</dc:creator>
      <dc:date>2020-09-28T15:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Today vs. Yesterday vs. Last Week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105299#M27307</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Comparing week-over-week results used to a pain in Splunk, with complex date calculations. No more.  Now there is a better way.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I wrote a convenient search command called "&lt;A href="http://apps.splunk.com/app/1645/"&gt;timewrap&lt;/A&gt;" that does it all, for arbitrary time periods.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart count span=1h | timewrap d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's it!&lt;/P&gt;

&lt;P&gt;&lt;A href="http://apps.splunk.com/app/1645/"&gt;http://apps.splunk.com/app/1645/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2014 18:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105299#M27307</guid>
      <dc:creator>carasso</dc:creator>
      <dc:date>2014-05-21T18:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Today vs. Yesterday vs. Last Week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105300#M27308</link>
      <description>&lt;P&gt;i would like to include prior week as well. i have modified query to like below mentioned but not working??&lt;/P&gt;

&lt;P&gt;index=access_json status&amp;gt;=400 earliest=-360h@h latest=@h &lt;BR /&gt;
| eval startToday = relative_time(now(),"-24h@h")&lt;BR /&gt;
| eval startYesterday = relative_time(now(),"-48h@h") &lt;BR /&gt;
| eval endLastWeek = relative_time(now(),"-168h@h")&lt;BR /&gt;
| eval priorLastWeek = relative_time(now(),"-336h@h")&lt;BR /&gt;
| eval marker = case(_time &amp;gt;= startToday, "Today",&lt;BR /&gt;
_time &amp;gt;=startYesterday,"Yesterday",&lt;BR /&gt;
_time &amp;lt;= endLastWeek,"Last Week",_time &amp;lt;= endLastWeek,"Prior Week",&lt;BR /&gt;
1=1,"Outside Range")&lt;BR /&gt;
| where marker != "Outside Range"&lt;BR /&gt;
| eval _time = case(marker="Today",_time,&lt;BR /&gt;
marker="Yesterday",_time+86400,&lt;BR /&gt;
marker="Last Week",_time+(7*86400), marker="Last Week",_time+(14*86400) )&lt;BR /&gt;
| timechart span=1h fixedrange=f count by marker&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:52:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105300#M27308</guid>
      <dc:creator>john_q</dc:creator>
      <dc:date>2020-09-29T20:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Today vs. Yesterday vs. Last Week</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105301#M27309</link>
      <description>&lt;P&gt;@john_q This thread is more than four years old with an accepted answer.  You have a better chance at getting a good response to your problem if you post a new question.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 10:21:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Today-vs-Yesterday-vs-Last-Week/m-p/105301#M27309</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-08-16T10:21:07Z</dc:date>
    </item>
  </channel>
</rss>

