<?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 edit my search to find the time frame window with the least amount of events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-time-frame-window-with-the/m-p/309448#M92825</link>
    <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| eval day_of_week = strftime(_time,"%A")
| eval hour=strftime(_time,"%H")
| where NOT (day_of_week="Saturday" OR day_of_week="Sunday") AND (hour&amp;gt;=9 AND hour&amp;lt;17)
| eval period=case(hour&amp;gt;=9 AND hour&amp;lt;12,"9 AM to 12 PM",hour&amp;gt;=12 AND hour&amp;lt;14,"12 PM to 2 PM",1=1,"2 PM to 5 PM")
| bin span=1d _time
| stats count dc(_time) as days by day_of_week period
| eval average_count = count/days
| sort 3 average_count
| eval day_of_week, period, count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Jul 2017 15:58:38 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-07-11T15:58:38Z</dc:date>
    <item>
      <title>How to edit my search to find the time frame window with the least amount of events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-time-frame-window-with-the/m-p/309447#M92824</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;

&lt;P&gt;I am trying to return the top 3 results of three hour windows where an event is least likely to happen based on the past 30 days during working hours (Monday - Friday 9am - 5pm).&lt;/P&gt;

&lt;P&gt;So far I have&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;event name here
 | eval day_of_week = strftime(_time,"%A")
 | where NOT (day_of_week="Saturday" OR day_of_week="Sunday")
 | bin span=1d _time
 | stats count dc(_time) as days by day_of_week
 | eval average_count = count / days
 | eventstats avg(average_count)
 | sort Average_Count | head 3
 | fields day_of_week, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am looking to return something like:&lt;BR /&gt;
Example: Monday 9am - 12pm, Monday 2pm - 5pm and Friday 2pm - 5pm.&lt;/P&gt;

&lt;P&gt;An ideas how to improve my search and return what I am looking for? Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:30:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-time-frame-window-with-the/m-p/309447#M92824</guid>
      <dc:creator>bamalone</dc:creator>
      <dc:date>2017-07-11T15:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the time frame window with the least amount of events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-time-frame-window-with-the/m-p/309448#M92825</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| eval day_of_week = strftime(_time,"%A")
| eval hour=strftime(_time,"%H")
| where NOT (day_of_week="Saturday" OR day_of_week="Sunday") AND (hour&amp;gt;=9 AND hour&amp;lt;17)
| eval period=case(hour&amp;gt;=9 AND hour&amp;lt;12,"9 AM to 12 PM",hour&amp;gt;=12 AND hour&amp;lt;14,"12 PM to 2 PM",1=1,"2 PM to 5 PM")
| bin span=1d _time
| stats count dc(_time) as days by day_of_week period
| eval average_count = count/days
| sort 3 average_count
| eval day_of_week, period, count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:58:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-time-frame-window-with-the/m-p/309448#M92825</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-11T15:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the time frame window with the least amount of events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-time-frame-window-with-the/m-p/309449#M92826</link>
      <description>&lt;P&gt;Thanks so much.&lt;/P&gt;

&lt;P&gt;However,  I would like to return the top 3 x 3 hour time slots with the least amount of events not specific to line 5 in your suggestion. &lt;/P&gt;

&lt;P&gt;Something like this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search
 | eval day_of_week = strftime(_time,"%A")
 | eval time= strftime(_time,"%m/%a")." ".strftime(_time,"%H %p")." - ".strftime(Max,"%H %p") 
 | fieldformat Max=strftime(Max,"%m/%a %H:%M")
 | tstats count latest(_time) as Max WHERE index=_internal BY _time span=3h
 | where NOT (day_of_week="Saturday" OR day_of_week="Sunday") AND (hour&amp;gt;=9 AND hour&amp;lt;17)
 | stats count dc(_time) as days by day_of_week period
 | eval average_count = count/days
 | sort 3 average_count
 | fields day_of_week, period, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the above does not seem to work, can you help me out? Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 08:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-time-frame-window-with-the/m-p/309449#M92826</guid>
      <dc:creator>bamalone</dc:creator>
      <dc:date>2017-07-12T08:44:45Z</dc:date>
    </item>
  </channel>
</rss>

