<?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 use 2 timeranges in a single search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-timeranges-in-a-single-search/m-p/10212#M407</link>
    <description>&lt;P&gt;I'd like to provide a table where the event count for today and yesterday are displayed.  For example, count by status for access logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status | today's count | yesterday's count
------------------------------------------
 404          10               13
 500          20               24
 503          15               10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;</description>
    <pubDate>Tue, 16 Mar 2010 23:07:20 GMT</pubDate>
    <dc:creator>hulahoop</dc:creator>
    <dc:date>2010-03-16T23:07:20Z</dc:date>
    <item>
      <title>How to use 2 timeranges in a single search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-timeranges-in-a-single-search/m-p/10212#M407</link>
      <description>&lt;P&gt;I'd like to provide a table where the event count for today and yesterday are displayed.  For example, count by status for access logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status | today's count | yesterday's count
------------------------------------------
 404          10               13
 500          20               24
 503          15               10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2010 23:07:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-timeranges-in-a-single-search/m-p/10212#M407</guid>
      <dc:creator>hulahoop</dc:creator>
      <dc:date>2010-03-16T23:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 2 timeranges in a single search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-timeranges-in-a-single-search/m-p/10213#M408</link>
      <description>&lt;P&gt;I guess I can use the &lt;CODE&gt;appendcols&lt;/CODE&gt; command, something like:&lt;/P&gt;

&lt;P&gt;sourcetype="access_combined" earliest=-1d@d | stats count as "today's count" by status | appendcols [search sourcetype=access_combined earliest=-2d@d latest=-1d@d | stats count as "yesterday's count" by status] | fields + status, "today's count","yesterday's count"&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2010 23:22:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-timeranges-in-a-single-search/m-p/10213#M408</guid>
      <dc:creator>hulahoop</dc:creator>
      <dc:date>2010-03-16T23:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 2 timeranges in a single search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-timeranges-in-a-single-search/m-p/10214#M409</link>
      <description>&lt;P&gt;You know this is just a 2-day timechart. If you're not that picky about the table layout:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="access_combined" earliest=-2d@d latest=@d | timechart span=1d count by status 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to which you can add:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval dy=now() | bucket dy span=1d | eval dy=if(_time=dy,"today","yesterday")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or if you are picky, this is how can transpose:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="access_combined" earliest=-2d@d latest=@d | chart count by status,_time span=1d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The column names will be wrong though, and they change every day, so you can't just use &lt;CODE&gt;rename&lt;/CODE&gt;. But the above is equivalent to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="access_combined" earliest=-2d@d latest=@d | bucket _time span=1d | stats count by status,_time | xyseries status _time count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which you then can to expand to (to fix the names of the columns):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="access_combined" earliest=-2d@d latest=@d  | bucket _time span=1d | stats count by status,_time | eval dy=now() | bucket dy span=1d | eval dy=if(_time=dy,"today","yesterday") | xyseries status dy count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And BTW, your "today" isn't today's count, it's yesterdays (midnight to midnight of the previous day), and your "yesterday" is two days ago. Adjust earliest and latest as appropriate.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2010 01:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-timeranges-in-a-single-search/m-p/10214#M409</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-03-17T01:06:20Z</dc:date>
    </item>
  </channel>
</rss>

