<?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: skip days and hours non-working to calculate SLA in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140392#M184835</link>
    <description>&lt;P&gt;The lookup approach has a big issue - performance. To determine whether an event is within the SLA period or not you need to load it, add the lookup, and then filter.&lt;/P&gt;

&lt;P&gt;I'd built a couple of macros, e.g. 5x8:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;((date_wday="monday" OR ... date_wday="friday") AND date_hour&amp;gt;=9 AND date_houry&amp;lt;17)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Use that in searches like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`5x8` AND index=test | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This way events outside the SLA rage don't even need to be loaded off disk.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jul 2014 07:33:32 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-07-14T07:33:32Z</dc:date>
    <item>
      <title>skip days and hours non-working to calculate SLA</title>
      <link>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140390#M184833</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;I am building an application to analyze my platform help desk, basically what I want is to build reports on compliance with the SLA, I have several clients and several SLAs Example: 7x24, 5x8, etc ... the dates of the tickets was unix format so that the calculation of direncia creating closure is provided, but as I can skip these days and times do not work according to the SLA calculations. &lt;/P&gt;

&lt;P&gt;Ej:&lt;/P&gt;

&lt;P&gt;index=prueba sourcetype=otrs state_ticket=closed | eventstats max(change_time) as lasttime by tn | dedup tn | convert ctime(lasttime) AS closing_date ctime(create_time_unix) AS create_ticket | eval timediff=(change_time-create_time_unix) | eval hour=floor(timediff / 3600) | eval min=floor((timediff / 60) % 60) | eval duracion=hour.":".min  | table tn,client,ticket_queue,priority_ticket,state_ticket,create_ticket,closing_date,agent,duration | sort -duration&lt;/P&gt;

&lt;P&gt;this query tells me the time takes me a ticket since its creation in transition to the closing.&lt;/P&gt;

&lt;P&gt;If someone can give me a hand, thanks for that.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:03:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140390#M184833</guid>
      <dc:creator>lufermalgo</dc:creator>
      <dc:date>2020-09-28T17:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: skip days and hours non-working to calculate SLA</title>
      <link>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140391#M184834</link>
      <description>&lt;P&gt;You can use couple o thing, maybe use date_wday together with date_hour to filter your results and will be enough for you...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test AND (date_wday="monday" OR date_wday="tuesday" OR...) AND (date_hour&amp;gt;=8 AND date_hours&amp;lt;=18) | stats count AS tickets_business_hours
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But a more sophisticated approach might be using a lookup table to check those values and return what sort of SLA it fits in. For example, Create a csv like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;date_wday, date_hour, sla
monday, 1, "24x7"
monday, 2, "24x7"
(...)
monday, 8, "8x5"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and use it as lookup:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test | lookup sla_periods date_wday, date_hour OUTPUT sla | count by sla
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can even do another lookup with the holiday after that, which will override the sla from the first lookup.&lt;/P&gt;

&lt;P&gt;Hope it helps!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:03:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140391#M184834</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2020-09-28T17:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: skip days and hours non-working to calculate SLA</title>
      <link>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140392#M184835</link>
      <description>&lt;P&gt;The lookup approach has a big issue - performance. To determine whether an event is within the SLA period or not you need to load it, add the lookup, and then filter.&lt;/P&gt;

&lt;P&gt;I'd built a couple of macros, e.g. 5x8:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;((date_wday="monday" OR ... date_wday="friday") AND date_hour&amp;gt;=9 AND date_houry&amp;lt;17)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Use that in searches like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`5x8` AND index=test | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This way events outside the SLA rage don't even need to be loaded off disk.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jul 2014 07:33:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140392#M184835</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-07-14T07:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: skip days and hours non-working to calculate SLA</title>
      <link>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140393#M184836</link>
      <description>&lt;P&gt;thanks musskopf and martin_mueller for the replies, &lt;/P&gt;

&lt;P&gt;I explain my situation a little more, the two ideas are very good but I think I'm wrong in asking the question. &lt;/P&gt;

&lt;P&gt;The SLA is defined in hours (Client 1 - 1 hour SLA, SLA Client 2 4 hours, etc. ..), and some of our customers have contracts 7x24 or 5x8, which I require to seek the best way to calculate the closing time of tickets depending on the SLA and the type of contract.&lt;/P&gt;

&lt;P&gt;Ej:&lt;BR /&gt;
business hours of the agents is from 8AM to 6PM, 7x24 for the contract serves other staff.&lt;/P&gt;

&lt;P&gt;name_client     SLA_hours      contract&lt;BR /&gt;
client1         2              7x24&lt;BR /&gt;
client2         4              5x8&lt;/P&gt;

&lt;P&gt;tn       client create_time change_time  status_ticket&lt;/P&gt;

&lt;P&gt;1111111      client1    1405119600  1407798000   closed&lt;/P&gt;

&lt;P&gt;2222222      client2    1405119600  1405350000   closed&lt;/P&gt;

&lt;P&gt;not meet the SLA client1 and client2 meets SLA&lt;/P&gt;

&lt;P&gt;for client2 should exclude Saturday and Sunday's hours on Friday night and early Monday. ie if the tiequete was created at 6PM on Friday and closed on Monday at 8AM time was 2 hours and the SLA was fulfilled.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:03:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140393#M184836</guid>
      <dc:creator>lufermalgo</dc:creator>
      <dc:date>2020-09-28T17:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: skip days and hours non-working to calculate SLA</title>
      <link>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140394#M184837</link>
      <description>&lt;P&gt;So, in my view you'll need to use the lookup approach, having  a table like that:&lt;/P&gt;

&lt;P&gt;client, date_wday, date_hour, SLA&lt;BR /&gt;
clientA, monday, 1, 2&lt;BR /&gt;
clientA, , 2, 2&lt;BR /&gt;
(...)&lt;BR /&gt;
clientB, , 8, 4&lt;/P&gt;

&lt;P&gt;After the lookup you'll have the SLA column for each event, where you can use a eval to define if the ticket met the SLA or not... could of IFs or CASEs.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:04:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/skip-days-and-hours-non-working-to-calculate-SLA/m-p/140394#M184837</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2020-09-28T17:04:08Z</dc:date>
    </item>
  </channel>
</rss>

