<?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: 24 hours time search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89061#M22806</link>
    <description>&lt;P&gt;Hi, no what i need is to count the events of the last 24 hours from now and to compare it with the daily average of the month with the same time interval.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Nov 2010 16:49:25 GMT</pubDate>
    <dc:creator>pinzer</dc:creator>
    <dc:date>2010-11-25T16:49:25Z</dc:date>
    <item>
      <title>24 hours time search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89058#M22803</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;sourcetype="sophos" pmx_action="keep" fur!="none" | bucket _time span=24h | timechart span="1d" count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi all, i need to do a search that count the events by 24 hours from the time when the search is started, also if is in the middle of a day and not at midnight.&lt;/P&gt;

&lt;P&gt;The search above counts by day but if i start the search at 2pm it counts only from midnight to 2pm and not from 2pm of the previous day to 2pm of this day.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2010 23:32:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89058#M22803</guid>
      <dc:creator>pinzer</dc:creator>
      <dc:date>2010-11-15T23:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: 24 hours time search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89059#M22804</link>
      <description>&lt;P&gt;One idea is just to use eval's now() and relative_time()  to muck with the _time values yourself: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | eval secondsElapsedToday = now()-relative_time(now(), "@d") | eval _time=_time-secondsElapsedToday | bucket _time span=1d&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The events that occurred between now and the same time yesterday will all have the timestamp of yesterday at midnight... &lt;/P&gt;

&lt;P&gt;if you want them all to have the timestamp of now(),  you'd just tack this onto the end to add the delta back after you've done the bucketing:: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval _time=_time+secondsElapsedToday&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;UPDATE: reading your comment, I think it's quite possible that all you need is something much simpler . Maybe you just want to run a search that does this? &lt;/P&gt;

&lt;P&gt;a) uses the time arguments to search &lt;EM&gt;only&lt;/EM&gt; from exactly -24h to now.   &lt;/P&gt;

&lt;P&gt;b) just counts the events.  period.  and you can divide that number by 24 if you want the average per hour. &lt;/P&gt;

&lt;P&gt;This would look like: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype="sophos" pmx_action="keep" fur!="none" | stats count | eval avg_count=count/24&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and the key thing again is to use the timerangepicker's custom mode to set the timerange to exactly (-24h,now)&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/User/ChangeTheTimeRangeOfYourSearch" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/User/ChangeTheTimeRangeOfYourSearch&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2010 05:42:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89059#M22804</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-11-16T05:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: 24 hours time search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89060#M22805</link>
      <description>&lt;P&gt;thanks a lot i've done this: &lt;/P&gt;

&lt;P&gt;sourcetype="sophos" pmx_action="keep" fur!="none" | eval secondsElapsedToday = now()-relative_time(now(), "@d") | eval _time=_time-secondsElapsedToday | bucket _time span=1d | stats count by _time | stats last(count) as today_count, avg(count) as avg_count &lt;/P&gt;

&lt;P&gt;but if the last day is without events this search shows the number of the previous day. How can i fix this? thanks a lot&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89060#M22805</guid>
      <dc:creator>pinzer</dc:creator>
      <dc:date>2020-09-28T09:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: 24 hours time search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89061#M22806</link>
      <description>&lt;P&gt;Hi, no what i need is to count the events of the last 24 hours from now and to compare it with the daily average of the month with the same time interval.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2010 16:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/24-hours-time-search/m-p/89061#M22806</guid>
      <dc:creator>pinzer</dc:creator>
      <dc:date>2010-11-25T16:49:25Z</dc:date>
    </item>
  </channel>
</rss>

