<?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 display the SLA status based on the SLA time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504073#M140884</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222107"&gt;@rock_s&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;The SPL as given above is already working for the case when&amp;nbsp;&lt;SPAN&gt;jobs are starting end of today and completing next day.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;This is the part that catches it:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(curr_date_hour&amp;lt;substr(SLA_start_time,1,2),"NOT_STARTED"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;So, if the start time of the Job is later than the current time, it assumes it has not yet started, not regarding the end time (because the end time does not matter in that case, it would not change the Status).&lt;BR /&gt;&lt;BR /&gt;It would fail though, when the start time is after midnight, does that happen for your use case? Are there Jobs that start e.g. at 1:00am and end at 4:00am?&lt;BR /&gt;&lt;BR /&gt;That would be one example where you'd need the date also, so you can be really sure what you compare (hour of today or tomorrow).&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;To your question about how to work with date and time, I can only give some hints without knowing your data better.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;First question would be, if you even have the date of start and end time already in your data? Or do you only get the hours as given in the table in your initial post? It would be dificult to guess the date in that case. You could assume everything&amp;nbsp; in end time that is&amp;nbsp;(e.g.) between 0:00am and 7:00am is "tomorrow", but not sure if that reflects your data.&lt;BR /&gt;&lt;BR /&gt;If you have the date, or can derive it somehow, the logic of my SPL would not change, but you would work with some strptime() and strftime()&amp;nbsp; (see&lt;A title="Date and Time functions" href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions" target="_self"&gt;&amp;nbsp;Date and Time Functions&lt;/A&gt;) before and after applying the Status.&lt;BR /&gt;I would get the Unix time of all dates with strptime(), apply the logic and then make it human readable again with strftime().&lt;BR /&gt;&lt;BR /&gt;We could help in more detail, when you show how your date fields look like (if you have date in your data). But I guess it helps to work with the documentation and try it for yourself first. (and if you are to some degree nerdish is also fun &lt;span class="lia-unicode-emoji" title=":nerd_face:"&gt;🤓&lt;/span&gt;).&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jun 2020 07:44:14 GMT</pubDate>
    <dc:creator>rnowitzki</dc:creator>
    <dc:date>2020-06-12T07:44:14Z</dc:date>
    <item>
      <title>How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/503694#M140881</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I have data as shown below, Whenever we run the search, if the current time is greater than start time we need to show the status as "Not Started", similar end time less the current time then status as Completed, if the current time is in b/w start time and end time then status as Running&lt;/P&gt;
&lt;P&gt;DATA:&lt;BR /&gt;job SLA_start_time SLA_end_time&lt;BR /&gt;abs 16:00 17:00&lt;BR /&gt;abc 20:00 23:00&lt;BR /&gt;mlp 23:00 01:00&lt;/P&gt;
&lt;P&gt;Expected output: if the current time hour is 18:00&lt;BR /&gt;job SLA_start_time SLA_end_time Status&lt;BR /&gt;abs 16:00 17:00 completed&lt;BR /&gt;abc 20:00 23:00 Not Started&lt;BR /&gt;zxc 18:00 19:00 Running&lt;BR /&gt;mlp 23:00 01:00 Not Started&lt;/P&gt;
&lt;P&gt;Note: here few of jobs are starting end of today and supposed to complete it next day early morning like 01:00 clock&lt;BR /&gt;please help me on this, thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 00:53:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/503694#M140881</guid>
      <dc:creator>rock_s</dc:creator>
      <dc:date>2020-06-16T00:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/503714#M140882</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I made up some sample data and it worked using this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval curr_date_hour = strftime(now(), "%H")

| eval status=if(curr_date_hour&amp;gt;substr(SLA_start_time,1,2) AND curr_date_hour&amp;gt;=substr(SLA_end_time,1,2), "COMPLETED", if(curr_date_hour&amp;lt;substr(SLA_start_time,1,2),"NOT_STARTED", if(curr_date_hour&amp;gt;=substr(SLA_start_time,1,2) AND curr_date_hour&amp;lt;substr(SLA_end_time,1,2),"RUNNING", "ERROR_IN_STATUS_DETECTION")))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: This is only looking at full hours, so you have issues like if start time is 18:30 and you check at 18:00, it would be considered as "RUNNING".&lt;BR /&gt;&lt;BR /&gt;It will be better to get the current time as HH:MM and also do the checks against that (so you can also get rid of the substr workaround).&amp;nbsp; It would be even better/safer if you have also the date for start and end time.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But just to give you an idea how you can set the logic up. Some Homework left for you &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 11:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/503714#M140882</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-06-10T11:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/503893#M140883</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64317"&gt;@rnowitzki&lt;/a&gt;&amp;nbsp;thanks for the replay, as I mentioned above few of jobs are starting end of today like 23:00 pm and completing next day early in the morning like 02:00 am. how can we solve this scenario, how the query will be if I use date and time(HH:MM) as you suggested. please help on this, Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 10:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/503893#M140883</guid>
      <dc:creator>rock_s</dc:creator>
      <dc:date>2020-06-11T10:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504073#M140884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222107"&gt;@rock_s&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;The SPL as given above is already working for the case when&amp;nbsp;&lt;SPAN&gt;jobs are starting end of today and completing next day.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;This is the part that catches it:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(curr_date_hour&amp;lt;substr(SLA_start_time,1,2),"NOT_STARTED"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;So, if the start time of the Job is later than the current time, it assumes it has not yet started, not regarding the end time (because the end time does not matter in that case, it would not change the Status).&lt;BR /&gt;&lt;BR /&gt;It would fail though, when the start time is after midnight, does that happen for your use case? Are there Jobs that start e.g. at 1:00am and end at 4:00am?&lt;BR /&gt;&lt;BR /&gt;That would be one example where you'd need the date also, so you can be really sure what you compare (hour of today or tomorrow).&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;To your question about how to work with date and time, I can only give some hints without knowing your data better.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;First question would be, if you even have the date of start and end time already in your data? Or do you only get the hours as given in the table in your initial post? It would be dificult to guess the date in that case. You could assume everything&amp;nbsp; in end time that is&amp;nbsp;(e.g.) between 0:00am and 7:00am is "tomorrow", but not sure if that reflects your data.&lt;BR /&gt;&lt;BR /&gt;If you have the date, or can derive it somehow, the logic of my SPL would not change, but you would work with some strptime() and strftime()&amp;nbsp; (see&lt;A title="Date and Time functions" href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions" target="_self"&gt;&amp;nbsp;Date and Time Functions&lt;/A&gt;) before and after applying the Status.&lt;BR /&gt;I would get the Unix time of all dates with strptime(), apply the logic and then make it human readable again with strftime().&lt;BR /&gt;&lt;BR /&gt;We could help in more detail, when you show how your date fields look like (if you have date in your data). But I guess it helps to work with the documentation and try it for yourself first. (and if you are to some degree nerdish is also fun &lt;span class="lia-unicode-emoji" title=":nerd_face:"&gt;🤓&lt;/span&gt;).&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 07:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504073#M140884</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-06-12T07:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504376#M140885</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64317"&gt;@rnowitzki&lt;/a&gt;&amp;nbsp;Thnaks for the replay and info.&lt;BR /&gt;&lt;BR /&gt;I have used the same as you suggested but the result is not as expected,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| eval curr_date_hour = strftime(now(), "%H")

| eval status=if(curr_date_hour&amp;gt;substr(SLA_start_time,1,2) AND curr_date_hour&amp;gt;=substr(SLA_end_time,1,2), "COMPLETED", if(curr_date_hour&amp;lt;substr(SLA_start_time,1,2),"NOT_STARTED", if(curr_date_hour&amp;gt;=substr(SLA_start_time,1,2) AND curr_date_hour&amp;lt;substr(SLA_end_time,1,2),"RUNNING", "ERROR_IN_STATUS_DETECTION")))&lt;/PRE&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;:&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="output.png" style="width: 556px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9183iE01DAB0E7959AE7C/image-dimensions/556x502?v=v2" width="556" height="502" role="button" title="output.png" alt="output.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here &lt;SPAN&gt;highlighted&amp;nbsp;&lt;/SPAN&gt;jobs are started at 6 pm, 8 pm, and 9 pm today and supposed to complete next day 01:00 am but still its showing completed, I was executed this search at 10 pm. please help on this same.&lt;/P&gt;&lt;P&gt;I have day field as date_mday which stores day value like 14, So i alerted the query to compare current day&amp;nbsp; with date_mday as shown below but no luck.&lt;/P&gt;&lt;P&gt;| eval curr_date_hour = strftime(now(), "%H")&lt;/P&gt;&lt;P&gt;| eval curr_day = strftime(now(), "%d")&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval status=if(curr_date_hour&amp;gt;substr(SLA_start_time,1,2) AND curr_date_hour&amp;gt;=substr(SLA_end_time,1,2), "COMPLETED", if(curr_date_hour&amp;lt;substr(SLA_start_time,1,2) AND (curr_day!=date_mday),"NOT_STARTED", if(curr_date_hour&amp;gt;=substr(SLA_start_time,1,2) AND curr_date_hour&amp;lt;substr(SLA_end_time,1,2),"RUNNING", "ERROR_IN_STATUS_DETECTION")))&lt;BR /&gt;&lt;BR /&gt;I have a fields like DATE=2020-06-14 date_mday=14 date_month=06 date_year=2020 SLA_start_time and SLA_end_time. Please help me this and thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 09:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504376#M140885</guid>
      <dc:creator>rock_s</dc:creator>
      <dc:date>2020-06-15T09:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504392#M140886</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222107"&gt;@rock_s&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Do you have a date field for the sla start- &lt;STRONG&gt;and&lt;/STRONG&gt; endtime?&lt;BR /&gt;I mean, you wrote that you have e.g.:&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;DATE=2020-06-14 date_mday=14 date_month=06 date_year=2020&lt;BR /&gt;&lt;/SPAN&gt;Do you have this for both of the SLA times?&lt;BR /&gt;&lt;BR /&gt;I see why the COMPLETED examples got wrong in your screenshot. It assumes it was completed, because the end time is smaller compared to the current time. So we have to include the date here.&lt;BR /&gt;&lt;BR /&gt;So, can you derive the whole date and time for the SLA start- and endtime?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 10:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504392#M140886</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-06-15T10:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504394#M140887</link>
      <description>&lt;P&gt;I adjusted the SPL a bit, so it does work. I would still suggest to integrate the date, if you access to the date for sla start- and endtime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval status=if(curr_date_hour&amp;gt;substr(SLA_start_time,1,2) AND curr_date_hour&amp;gt;=substr(SLA_end_time,1,2) AND SLA_start_time &amp;lt; SLA_end_time, "COMPLETED", if(curr_date_hour&amp;lt;substr(SLA_start_time,1,2),"NOT_STARTED", if(curr_date_hour&amp;gt;=substr(SLA_start_time,1,2) AND (curr_date_hour&amp;lt;substr(SLA_end_time,1,2) OR SLA_start_time &amp;gt; SLA_end_time),"RUNNING", "ERROR_IN_STATUS_DETECTION")))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I adjusted the detection of COMPLETED&amp;nbsp; by adding "AND SLA_start_time &amp;lt; SLA_end_time"&amp;nbsp; and for RUNNING ones by adding&amp;nbsp; "OR SLA_start_time &amp;gt; SLA_end_time",&amp;nbsp; assuming the sla end hour is smaller when it is refering to the next date.&lt;/P&gt;&lt;P&gt;This might not work for all cases. It would be more clean to work with the whole date. Also it might be more readable working with &lt;EM&gt;case&lt;/EM&gt; instead of &lt;EM&gt;ifs&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 10:42:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504394#M140887</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-06-15T10:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504403#M140888</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64317"&gt;@rnowitzki&lt;/a&gt;&amp;nbsp;, Thanks for the quick replay,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have only these fields like DATE=2020-06-14 date_mday=14 date_month=06 date_year=2020 SLA_start_time=16:00 and SLA_end_time=17:00 in each event. but values are the different in each event&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face_with_tongue:"&gt;😜&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;can we include date or date_mday to get as we required like this??&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-SPOILER&gt;| eval status=if(curr_date_hour&amp;gt;substr(SLA_start_time,1,2) AND curr_date_hour&amp;gt;=substr(SLA_end_time,1,2) AND SLA_start_time &amp;lt; SLA_end_time, "COMPLETED", if(curr_date_hour&amp;lt;substr(SLA_start_time,1,2) AND (current_day!=date_mday),"NOT_STARTED", if(curr_date_hour&amp;gt;=substr(SLA_start_time,1,2) AND (curr_date_hour&amp;lt;substr(SLA_end_time,1,2) OR SLA_start_time &amp;gt; SLA_end_time),"RUNNING", "ERROR_IN_STATUS_DETECTION")))&lt;/LI-SPOILER&gt;</description>
      <pubDate>Mon, 15 Jun 2020 11:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504403#M140888</guid>
      <dc:creator>rock_s</dc:creator>
      <dc:date>2020-06-15T11:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504408#M140889</link>
      <description>&lt;P&gt;Well, it seems to me as if your date fields are not refering to the sla end/start time.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;So, you actually have only the hour for the sla times.&lt;BR /&gt;&lt;BR /&gt;In that case, I can not think of another solution than already posted above. (to assume the end_hour is refering to the next day if it is "smaller" than the start_hour)&lt;BR /&gt;&lt;BR /&gt;Did you try my last SPL?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 11:32:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504408#M140889</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-06-15T11:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504412#M140890</link>
      <description>&lt;LI-CODE lang="markup"&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;SLA sample&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="dropdown" token="time"&amp;gt;
      &amp;lt;label&amp;gt;time&amp;lt;/label&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;time&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;_time&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;| makeresults count=2
| streamstats count
| eval _time=if(count=1,relative_time(_time,"-1d@d"),relative_time(_time,"@d"))
| makecontinuous _time span=1h
| eval _time=strftime(_time,"%H:%M")
| eval time=_time
| filldown
| where count=1&amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
      &amp;lt;prefix&amp;gt;"&amp;lt;/prefix&amp;gt;
      &amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| eval _raw="job,SLA_start_time,SLA_end_time
abs,16:00,17:00
abc,20:00,23:00
zxc,18:00,19:00
mlp,23:00,01:00"
| multikv forceheader=1
| table job,SLA_start_time,SLA_end_time
| eval Status=case(strptime($time$,"%H:%M")&amp;amp;lt;strptime(SLA_start_time,"%H:%M"),"Not Started"
, strptime($time$,"%H:%M")&amp;amp;gt;=strptime(SLA_start_time,"%H:%M") AND strptime($time$,"%H:%M")&amp;amp;lt;=strptime(SLA_end_time,"%H:%M"),"RUNNING"
, strptime($time$,"%H:%M")&amp;amp;gt;strptime(SLA_end_time,"%H:%M"),"completed")&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;How about &lt;STRONG&gt;relative_time()&lt;/STRONG&gt; ?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 11:51:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/504412#M140890</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-06-15T11:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/505418#M141237</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64317"&gt;@rnowitzki&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Now Iam able to get the data for sla start time and sla end time including date as well as shown below.&lt;/P&gt;&lt;P&gt;DATE=2020-06-14 date_mday=14 date_month=06 date_year=2020 SLA_start_time=16:00 SLA_start_date= 061320 and SLA_end_time=17:00 SLA_end_date=061420(MMDDYY). Plz help me on this, Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 04:02:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/505418#M141237</guid>
      <dc:creator>rock_s</dc:creator>
      <dc:date>2020-06-22T04:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/505437#M141244</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222107"&gt;@rock_s&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;This is now comparing the current time with the SLA start and end time including date, hour, minute:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval SLA_start_datetime=strptime(SLA_start_date+SLA_start_time, "%m%d%y%H:%M")
| eval SLA_end_datetime=strptime(SLA_end_date+SLA_end_time, "%m%d%y%H:%M")
| eval curr_datetime = now()

| eval status=case(SLA_start_datetime&amp;gt;curr_datetime, "NOT_STARTED", SLA_start_datetime&amp;lt;curr_datetime AND SLA_end_datetime&amp;lt;=curr_datetime, "COMPLETED",SLA_start_datetime&amp;lt;=curr_datetime AND SLA_end_datetime&amp;gt;curr_datetime, "RUNNING")

| eval SLA_start_datetime=strftime(SLA_start_datetime, "%m%d%y %H:%M")
| eval SLA_end_datetime=strftime(SLA_end_datetime, "%m%d%y %H:%M")
| eval curr_datetime = strftime(curr_datetime, "%m%d%y %H:%M")

| fields job SLA_start_datetime SLA_end_datetime curr_datetime status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first block adds together start/end date and time and converts it to unix time, also adds the current time as unix time.&lt;/P&gt;&lt;P&gt;The second block sets the status.&lt;/P&gt;&lt;P&gt;The third block converts the date fields back to human readable format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the last line, with &lt;EM&gt;fields&lt;/EM&gt; just puts together the final output table.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 08:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/505437#M141244</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-06-22T08:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/507809#M141949</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/64317"&gt;@rnowitzki&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for the replay, Its working as expected, but I would like include the not_completed count as well like as shown blow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;| eval status=case(SLA_start_datetime&amp;gt;curr_datetime, "NOT_STARTED", SLA_start_datetime&amp;lt;curr_datetime AND SLA_end_datetime&amp;lt;=curr_datetime OR not_completed!=0, "COMPLETED",SLA_start_datetime&amp;lt;=curr_datetime AND SLA_end_datetime&amp;gt;curr_datetime, "RUNNING")&lt;/P&gt;&lt;P&gt;&amp;nbsp;above case also working as expected but where i am getting the problem is when the job is completed(SLE end time reached) at that time if not_completed count is not equal to 0 then Status should be "SLA Not Completed/Met" after some time(after sla end time) not_completed=0 its becoming "Completed"&lt;BR /&gt;Working now:&lt;BR /&gt;when the job is completed(SLA end time reached) at that time if not_completed count not equal to 0 then Status should be "SLA Not Completed/Met"&lt;BR /&gt;Expected:&lt;BR /&gt;when the job is completed(SLA end time reached) at that time if not_completed count not equal to 0 then Status should be "SLA Not Completed/Met"&amp;nbsp; after some time count is equal to 0 even though&amp;nbsp; Status should be "Not Completed/Met" for that day why because its SLA missed for that day with in sla allocated time.&lt;/P&gt;&lt;P&gt;Please help on this, thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 11:24:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/507809#M141949</guid>
      <dc:creator>rock_s</dc:creator>
      <dc:date>2020-07-07T11:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the SLA status based on the SLA time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/508779#M142144</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222107"&gt;@rock_s&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I don't really understand the latest requirement.&lt;BR /&gt;&lt;BR /&gt;Can you please just give an example output table as you need it, with some sample data. I guess it is easier to understand with that.&lt;BR /&gt;&lt;BR /&gt;Thx&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 10:27:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-SLA-status-based-on-the-SLA-time/m-p/508779#M142144</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-07-13T10:27:55Z</dc:date>
    </item>
  </channel>
</rss>

