<?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: Search a particular time of day across multiple days in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73265#M181064</link>
    <description>&lt;P&gt;You can use an eval function (or an automatic calculated field) based on "date_hour" to identify the time of the day.&lt;/P&gt;

&lt;P&gt;Then use it as a condition over several days.&lt;/P&gt;

&lt;P&gt;example of number of events per day per timeofday.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;*  | eval timeofday=case(date_hour&amp;gt;=6 AND date_hour&amp;lt;8,"Morning",&lt;BR /&gt;
date_hour&amp;gt;=8 AND date_hour&amp;lt;18,"Day Off Peak",&lt;BR /&gt;
date_hour&amp;gt;=18 AND date_hour&amp;lt;23,"Prime Time", &lt;BR /&gt;
date_hour&amp;gt;=23 OR date_hour&amp;lt;6,"Night Off Peak",&lt;BR /&gt;
1=1,"error") | timechart span=1d count by timeofday&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2013 20:03:39 GMT</pubDate>
    <dc:creator>yannK</dc:creator>
    <dc:date>2013-09-25T20:03:39Z</dc:date>
    <item>
      <title>Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73264#M181063</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm trying to map out usage by time of day:&lt;/P&gt;

&lt;P&gt;Morning (6am-8am)&lt;BR /&gt;
Day Off Peak (8am-6pm)&lt;BR /&gt;
Prime Time (6pm-11pm)&lt;BR /&gt;
Night Off Peak (11pm-6am)&lt;/P&gt;

&lt;P&gt;I'd like to be able to count events in these time slots across multiple days (for example a count of events in the last week that occurred during the Morning time slot).&lt;/P&gt;

&lt;P&gt;Looking at the earliest and latest command, I don't see a way to snap that on a moving basis. Something like earliest=@d+6h latest=@d+8h for last seven days. Is there another way?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 18:51:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73264#M181063</guid>
      <dc:creator>sambiggins</dc:creator>
      <dc:date>2013-09-25T18:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73265#M181064</link>
      <description>&lt;P&gt;You can use an eval function (or an automatic calculated field) based on "date_hour" to identify the time of the day.&lt;/P&gt;

&lt;P&gt;Then use it as a condition over several days.&lt;/P&gt;

&lt;P&gt;example of number of events per day per timeofday.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;*  | eval timeofday=case(date_hour&amp;gt;=6 AND date_hour&amp;lt;8,"Morning",&lt;BR /&gt;
date_hour&amp;gt;=8 AND date_hour&amp;lt;18,"Day Off Peak",&lt;BR /&gt;
date_hour&amp;gt;=18 AND date_hour&amp;lt;23,"Prime Time", &lt;BR /&gt;
date_hour&amp;gt;=23 OR date_hour&amp;lt;6,"Night Off Peak",&lt;BR /&gt;
1=1,"error") | timechart span=1d count by timeofday&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 20:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73265#M181064</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-09-25T20:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73266#M181065</link>
      <description>&lt;P&gt;Perfect, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 20:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73266#M181065</guid>
      <dc:creator>sambiggins</dc:creator>
      <dc:date>2013-09-25T20:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73267#M181066</link>
      <description>&lt;P&gt;Have you looked at the &lt;CODE&gt;date_*&lt;/CODE&gt; fields? They are automatically extracted for most types of log files, but not all. The timestamp in your event is used for determining the the time the event should be indexed under, but it is also broken down into the &lt;CODE&gt;date_*&lt;/CODE&gt; fields, e.g. &lt;CODE&gt;date_wday, date_mday, date_hour&lt;/CODE&gt; etc. &lt;/P&gt;

&lt;P&gt;If you live in an area where a 12-hour time notation is used in the event timestamps, this is somewhat less useful, and you might be better off by manually extracting the relevant part out of the &lt;CODE&gt;_time&lt;/CODE&gt; field (in the 24-hour notation).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval hr = strftime(_time, "%H") 
| eval slot = "Night Off Peak" 
| eval slot = case((hr &amp;gt; 5 AND hr &amp;lt; 8), "Morning", (hr &amp;gt; 7 AND hr &amp;lt; 18), "Day Off Peak", (hr &amp;gt; 17 AND hr &amp;lt; 23), "Prime Time") 
| timechart span=1d count by slot
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first &lt;CODE&gt;eval&lt;/CODE&gt; (hr) will get the hour (0-23) from the timestamp. The second &lt;CODE&gt;eval&lt;/CODE&gt; will just set a default value for the &lt;CODE&gt;slot&lt;/CODE&gt; field. The third &lt;CODE&gt;eval&lt;/CODE&gt; will override the value of &lt;CODE&gt;slot&lt;/CODE&gt; for specific values of &lt;CODE&gt;hr&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 20:19:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73267#M181066</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-09-25T20:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73268#M181067</link>
      <description>&lt;P&gt;dammit!!&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 20:19:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73268#M181067</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-09-25T20:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73269#M181068</link>
      <description>&lt;P&gt;too slow little grasshopper &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 20:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73269#M181068</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-09-25T20:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73270#M181069</link>
      <description>&lt;P&gt;The answer above was the first I'd seem them. Quite handy! Thanks for chiming in &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 21:53:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73270#M181069</guid>
      <dc:creator>sambiggins</dc:creator>
      <dc:date>2013-09-25T21:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73271#M181070</link>
      <description>&lt;P&gt;This is exactly what I was looking for. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 16:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/73271#M181070</guid>
      <dc:creator>DBattisto</dc:creator>
      <dc:date>2018-09-19T16:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/567144#M197636</link>
      <description>&lt;P&gt;Hi All, I need daily counts of events between 9PM&amp;nbsp; (lets say yesterday)&amp;nbsp; to 5 AM (today), this pattern i need for last 30 days. Could you please let me know what should be my search.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying this but it returns nothing:&lt;/P&gt;&lt;P&gt;eventtype=eks_prd_logs sourcetype="kube:container:*crs-maint" earliest=-31@d latest=-1@d (date_hour &amp;gt; 21 AND date_hour &amp;lt; 5)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help asap.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 17:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/567144#M197636</guid>
      <dc:creator>MayankChandra</dc:creator>
      <dc:date>2021-09-15T17:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Search a particular time of day across multiple days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/667733#M229070</link>
      <description>&lt;P&gt;This is years later but I'm hoping someone will be able to answer and see this. What is the 1=1, "error" referring to? I understand that if 1=1, then that adds one to "error", but that's the extent of my understanding.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 19:01:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-a-particular-time-of-day-across-multiple-days/m-p/667733#M229070</guid>
      <dc:creator>yoshileigh66</dc:creator>
      <dc:date>2023-11-07T19:01:57Z</dc:date>
    </item>
  </channel>
</rss>

