<?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 can I exclude a specific recurring time range from my search? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299346#M56617</link>
    <description>&lt;P&gt;It's not exact result, but close to the expectations. Needs more tweaking.&lt;/P&gt;</description>
    <pubDate>Sun, 15 Oct 2017 15:13:13 GMT</pubDate>
    <dc:creator>qbolbk59</dc:creator>
    <dc:date>2017-10-15T15:13:13Z</dc:date>
    <item>
      <title>How can I exclude a specific recurring time range from my search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299342#M56613</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I need to create a dashboard which can provide me the total review time taken by the analyst. I have created the following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel Incident_Management Notable_Events search | stats earliest(_time) as _time by rule_id  | `drop_dm_object_name("Notable_Events")`| `get_correlations` | join rule_id [| datamodel Incident_Management Incident_Review search  | stats earliest(_time) as reviewtime by Incident_Review.rule_id,Incident_Review.reviewer_realname| `drop_dm_object_name("Incident_Review")`] | eval tot=reviewtime-_time | stats count,avg(tot) as avg_tot,max(tot) as max_tot ,min(tot) as min_tot by reviewer_realname | sort - avg_tot | `uptime2string(avg_tot, avg_tot)` | `uptime2string(max_tot, max_tot)` | `uptime2string(min_tot, min_tot)` |rename *_tot* as *_time_to_review* | fields - *_dec
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is working fine and giving me results close to my expectations. However i don't need to include the off-business hours in the review time. For e.g., if i acknowledged and alert today and i closed it tomorrow, the total review time should not have the Off-business hour time (possibly 8-10 hours) and it should get subtracted.&lt;/P&gt;

&lt;P&gt;Can anybody help me here on this issue ?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 14:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299342#M56613</guid>
      <dc:creator>qbolbk59</dc:creator>
      <dc:date>2017-10-06T14:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I exclude a specific recurring time range from my search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299343#M56614</link>
      <description>&lt;P&gt;this is an interesting problem...just to be clear-&lt;BR /&gt;
eval tot=reviewtime-_time &lt;BR /&gt;
review time is like a start time and the _time is like an end time for each ticket?&lt;BR /&gt;
basically, you already have for each event the reviewtime like say&lt;BR /&gt;
event reviewtime(start time) is 10:00 am on a monday&lt;BR /&gt;
and the&lt;BR /&gt;
_time (end time) is like say 10:00 AM on Wednesday?&lt;BR /&gt;
so assuming an 8 hr work day 8:00 - 16:00&lt;BR /&gt;
your eval tot should be 6 hrs (mon) + 8 hrs(tue) + 2 hrs(wed)= 16?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 09:06:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299343#M56614</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-10-08T09:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: How can I exclude a specific recurring time range from my search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299344#M56615</link>
      <description>&lt;P&gt;If you absolutely never have a situation where an analyst works on a ticket for more than one work day... i.e., never count more than the work hours during the first and second day :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval daydiff= floor(reviewtime/86400) - floor(_time/86400)
 | eval tot = case(daydiff&amp;lt;=0, reviewtime - _time,
                   daydiff=1, reviewtime - _time - 16*3600,
                   daydiff&amp;gt;1, reviewtime - _time + 8* 3600 - daydiff*86400)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;On the other hand, if you want to count all 9-5 hours regardless of weekday or weekend, use this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval daydiff= floor(reviewtime/86400) - floor(_time/86400)
 | eval tot = case(daydiff&amp;lt;=0, reviewtime - _time,
                   daydiff&amp;gt;=1, reviewtime - _time - daydiff*16*3600)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And, if you want to count off for weekends, but not for weekdays, then there will be some complicated logic that I can't rattle off without checking the time functions.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 15:39:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299344#M56615</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-10T15:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I exclude a specific recurring time range from my search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299345#M56616</link>
      <description>&lt;P&gt;Hi @DalJeanis&lt;/P&gt;

&lt;P&gt;Thanks for helping. The normal working hours is 12 hours a day and 7 days a week.  so if an alert was triggered today and it got closed tomorrow, i need to remove the 12 off business hours from the total time taken. similarly if it got closed after two days, i need to remove 24 hours (2*12) and so on.  I used the logic provided by you and modified it a bit and now have used the below query and it seems that now it's rendering me exact results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel Incident_Management Notable_Events search | stats earliest(_time) as _time by rule_id | `get_correlations` | join rule_id [| datamodel Incident_Management Incident_Review search  | stats earliest(_time) as reviewtime by Incident_Review.rule_id,reviewer_realname | `drop_dm_object_name("Incident_Review")`] | eval tot=reviewtime-_time |eval tot1=round(tot/86400) | eval tot2=(tot-(tot1*43200)) |stats count,avg(tot2) as avg_tot,max(tot2) as max_tot ,min(tot2) as min_tot by reviewer_realname | sort - avg_tot | `uptime2string(avg_tot, avg_tot)` | `uptime2string(max_tot, max_tot)` | `uptime2string(min_tot, min_tot)` |rename *_tot* as *_time_to_review* | fields - *_dec
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Oct 2017 15:03:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299345#M56616</guid>
      <dc:creator>qbolbk59</dc:creator>
      <dc:date>2017-10-15T15:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I exclude a specific recurring time range from my search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299346#M56617</link>
      <description>&lt;P&gt;It's not exact result, but close to the expectations. Needs more tweaking.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2017 15:13:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-exclude-a-specific-recurring-time-range-from-my-search/m-p/299346#M56617</guid>
      <dc:creator>qbolbk59</dc:creator>
      <dc:date>2017-10-15T15:13:13Z</dc:date>
    </item>
  </channel>
</rss>

