<?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 search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237497#M70579</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;your search earliest=-60m@m latest=@m| stats min(_time) as _time count as Count | eval Day="Today" | fields Day, _time, Count | append [ search your search earliest=-1d@m-60m latest=-1d@m | stats min(_time) as _time count as Count | eval Day="Yesterday" | fields Day, _time, Count ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Oct 2016 23:48:28 GMT</pubDate>
    <dc:creator>twinspop</dc:creator>
    <dc:date>2016-10-07T23:48:28Z</dc:date>
    <item>
      <title>How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237495#M70577</link>
      <description>&lt;P&gt;How to get the count of an event (say logins) in last sixty minutes and the count of same event for same hour yesterday? Result should be as:&lt;/P&gt;

&lt;P&gt;Today hh:mm:ss Count&lt;BR /&gt;
Yesterday hh:mm:ss Count&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 23:41:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237495#M70577</guid>
      <dc:creator>govindsinghrawa</dc:creator>
      <dc:date>2016-10-07T23:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237496#M70578</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search earliest=-1d@d | eval when=if(_time&amp;gt;relative_time(now(), "@d"), "Today", "Yesterday") | eval t=strftime(_time, "%H") | chart count over t by when
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Oct 2016 23:47:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237496#M70578</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-07T23:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237497#M70579</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;your search earliest=-60m@m latest=@m| stats min(_time) as _time count as Count | eval Day="Today" | fields Day, _time, Count | append [ search your search earliest=-1d@m-60m latest=-1d@m | stats min(_time) as _time count as Count | eval Day="Yesterday" | fields Day, _time, Count ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Oct 2016 23:48:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237497#M70579</guid>
      <dc:creator>twinspop</dc:creator>
      <dc:date>2016-10-07T23:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237498#M70580</link>
      <description>&lt;P&gt;we can use date_hour and solve this specific timeframe issue.&lt;BR /&gt;
Try this one -&lt;/P&gt;

&lt;P&gt;index=main sourcetype=yourSourcetype earliest=-2d latest=now (date_hour &amp;gt; 1 OR date_hour &amp;lt; 2) | chart count(Failure) by host&lt;/P&gt;

&lt;P&gt;Instead of chart, you use &lt;BR /&gt;
|stats count AS Count&lt;/P&gt;

&lt;P&gt;The date_hour, earliest /latest, combinations can be fine tuned.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:20:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237498#M70580</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2020-09-29T11:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237499#M70581</link>
      <description>&lt;P&gt;getting data for all hours and not just one hour of today and yesterday same hour&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2016 00:10:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237499#M70581</guid>
      <dc:creator>govindsinghrawa</dc:creator>
      <dc:date>2016-10-08T00:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237500#M70582</link>
      <description>&lt;P&gt;seems to work, thanks&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2016 00:10:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237500#M70582</guid>
      <dc:creator>govindsinghrawa</dc:creator>
      <dc:date>2016-10-08T00:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237501#M70583</link>
      <description>&lt;P&gt;will it not just return for 1st and 2nd hour and not for 60 minutes ago from now. I will try though but seems not to be complete. Thanks a lot for helping out though&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2016 00:17:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237501#M70583</guid>
      <dc:creator>govindsinghrawa</dc:creator>
      <dc:date>2016-10-08T00:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237502#M70584</link>
      <description>&lt;P&gt;I don't ever trust date_hour. Lots of past discussion on this. Search the archives.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2016 01:13:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237502#M70584</guid>
      <dc:creator>twinspop</dc:creator>
      <dc:date>2016-10-08T01:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237503#M70585</link>
      <description>&lt;P&gt;Lets assume that the event you have can be uniquely identified by &lt;STRONG&gt;&lt;EM&gt;yourBaseSearch&lt;/EM&gt;&lt;/STRONG&gt;, so your base search should return you unique events for whatever you are counting, then search twice and append them.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;One search to return today's count for an hour ago
&lt;PRE&gt;
yourBaseSearch earliest=-60m latest=now()
|fields anyFieldOfyoursToEnsureCountingOfEvents
| timechart span=1m count 
| eval _time=_time-now()%3600 
| timechart span=1h sum(count) as count 
| tail 3 | tail 2 
| eval _time=_time+now()%3600
|tail 1 
&lt;/PRE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;SubSearch to return yesterday's count by shifting earliest and latest by 25 and 24 hours(in minutes to be accurate till minutes):&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
search yourBaseSearchAgain earliest=-1500m latest=-1440m &lt;BR /&gt;
| timechart span=1m count &lt;BR /&gt;
| eval _time=_time-now()%3600 &lt;BR /&gt;
| timechart span=1h sum(count) as count &lt;BR /&gt;
| tail 3 | tail 2 &lt;BR /&gt;
| eval _time=_time+now()%3600&lt;BR /&gt;
|tail 1&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Append search 1 and 2&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;PRE&gt;
search1Above
|append [search2Above]
|sort +_time
&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; _time=_time-now()%3600 is given just to push the time in display to return the time correctly to represent since when the count is being taken.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:20:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237503#M70585</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2020-09-29T11:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of an event for the last sixty minutes, and the count of the same event for the same hour yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237504#M70586</link>
      <description>&lt;P&gt;tested it as an answer post . seems to be working .&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2016 22:28:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-an-event-for-the-last-sixty-minutes/m-p/237504#M70586</guid>
      <dc:creator>govindsinghrawa</dc:creator>
      <dc:date>2016-10-08T22:28:17Z</dc:date>
    </item>
  </channel>
</rss>

