<?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 calculate downtime or time difference within a custom date time range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633150#M219936</link>
    <description>&lt;P&gt;Tried something like this using this but no luck. Even after I exclude the events (downtime beginning and downtime end timestamps) the downtime calculation didn't change.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| eval time=strftime(_time,"%H:%M")&lt;BR /&gt;| search time != 16:30 AND time != 01:35 AND time != 01:40&lt;BR /&gt;| eval up=if(SampleCount &amp;gt;= 5, 1, null())&lt;BR /&gt;| streamstats window=2 global=f range(_time) as diff by up&lt;BR /&gt;| eval downtime=if(diff-300&amp;gt;0,diff-300,null())&lt;BR /&gt;| eval uptime=if(up=1, 300,0)&lt;BR /&gt;| table timestamp time up diff downtime uptime&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="After excluding" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24175i09970D79C505EFF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="after excluding downtime events.jpg" alt="After excluding" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;After excluding&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Before excluding" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24174iC3B4E2B50DEA1FBA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="before excluding downtime events.jpg" alt="Before excluding" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Before excluding&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2023 12:32:18 GMT</pubDate>
    <dc:creator>sh254087</dc:creator>
    <dc:date>2023-03-03T12:32:18Z</dc:date>
    <item>
      <title>How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/632986#M219890</link>
      <description>&lt;P&gt;This is in continuation to my query(resolved) here -&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Enterprise/How-to-check-time-difference-between-a-series-of-events/m-p/632616" target="_blank"&gt;Solved: How to check time difference between a series of e... - Splunk Community&amp;nbsp;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here I was able to get the overall downtime for any selected time range by using SUM() and AVG() after teh suggested solution.&lt;/P&gt;&lt;P&gt;In continuation to the sample scenario explained in the aforementioned query, I have to now handle a scheduled downtime.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a process which turns our servers down at 4:30 pm and brings them up at 1:30am UTC time &amp;nbsp;, automatically on a schedule, every day. The 9 hrs 10mins downtime which is shown in the sample is of the same.&lt;/P&gt;&lt;P&gt;In this case I was able to come up with unplanned&amp;nbsp;downtime by subtracting 9:10 from total downtime as it was a specific selected time range :&amp;nbsp;2023-02-21T16:00:00Z to&amp;nbsp;2023-02-22T02:25:00Z and as there was only one record of 9hrs 10min downtime.&amp;nbsp; However, we have noticed few other scenarios which are a bit complex, like -&lt;/P&gt;&lt;P&gt;1. When the time range selected is 24 hrs or yesterday (3/1/23 12:00:00.000 AM to 3/2/23 12:00:00.000 AM), assuming the system was up all the time outside the scheduled downtime, the total downtime will be shown as empty/null as the first event for the day will be at 1:35 and last one at 16:30 and no other downtime in between. (this is still okay, as I just have to handle the null downtime with a zero)&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. When the time range selected is anything more than a day, say 7days or 30 days or even a random custom date time range, I'm not sure how to calculate the actual downtime.&lt;BR /&gt;Can this be handled somehow?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 12:14:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/632986#M219890</guid>
      <dc:creator>sh254087</dc:creator>
      <dc:date>2023-03-02T12:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/632994#M219891</link>
      <description>&lt;P&gt;Can you not calculate the time HHMM from the timestamp and ignore events which are in the scheduled downtime period?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 12:53:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/632994#M219891</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-02T12:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633113#M219926</link>
      <description>&lt;P&gt;Working with date and time is very new to me and I'm not able to figure this up.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 07:59:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633113#M219926</guid>
      <dc:creator>sh254087</dc:creator>
      <dc:date>2023-03-03T07:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633117#M219929</link>
      <description>&lt;LI-CODE lang="markup"&gt;| eval time=strftime(_time,"%H%M")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Mar 2023 08:45:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633117#M219929</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-03T08:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633150#M219936</link>
      <description>&lt;P&gt;Tried something like this using this but no luck. Even after I exclude the events (downtime beginning and downtime end timestamps) the downtime calculation didn't change.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| eval time=strftime(_time,"%H:%M")&lt;BR /&gt;| search time != 16:30 AND time != 01:35 AND time != 01:40&lt;BR /&gt;| eval up=if(SampleCount &amp;gt;= 5, 1, null())&lt;BR /&gt;| streamstats window=2 global=f range(_time) as diff by up&lt;BR /&gt;| eval downtime=if(diff-300&amp;gt;0,diff-300,null())&lt;BR /&gt;| eval uptime=if(up=1, 300,0)&lt;BR /&gt;| table timestamp time up diff downtime uptime&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="After excluding" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24175i09970D79C505EFF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="after excluding downtime events.jpg" alt="After excluding" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;After excluding&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Before excluding" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24174iC3B4E2B50DEA1FBA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="before excluding downtime events.jpg" alt="Before excluding" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Before excluding&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 12:32:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633150#M219936</guid>
      <dc:creator>sh254087</dc:creator>
      <dc:date>2023-03-03T12:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633153#M219937</link>
      <description>&lt;P&gt;Why would you change from my suggestion?&lt;/P&gt;&lt;P&gt;Try without the : so that the hours and minutes becomes a single number e.g. 09:30 becomes 0930 (930) then you can compare it with another number e.g. 1000 or 2330 and do a simple arithmetic comparison e.g. is it between 1630 and 2300, or whatever your time constraints are.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 12:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633153#M219937</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-03T12:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633171#M219946</link>
      <description>&lt;P&gt;I was, but,&amp;nbsp; just trying different possibilities while I took the screenshot.&lt;BR /&gt;&lt;BR /&gt;I had tried keeping it as is, but the comparison that I tried hadn't worked. Was getting like this -&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sh254087_0-1677850835515.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24178i934F8A9CF8FB6029/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sh254087_0-1677850835515.png" alt="sh254087_0-1677850835515.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Even if I change this limit like - 'time&amp;lt;1625' instead of 'time&amp;lt;1630', the downtime doesn't change.&amp;nbsp;&lt;BR /&gt;It just don't display those rows, but are somehow being considered for the downtime calculation.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sh254087_1-1677851394396.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24179i235EC1C8C59FE3ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sh254087_1-1677851394396.png" alt="sh254087_1-1677851394396.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 13:49:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633171#M219946</guid>
      <dc:creator>sh254087</dc:creator>
      <dc:date>2023-03-03T13:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: How  to calculate downtime or time difference within a custom date time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633179#M219949</link>
      <description>&lt;P&gt;Try moving it to after the streamstats!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 14:20:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-downtime-or-time-difference-within-a-custom/m-p/633179#M219949</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-03T14:20:14Z</dc:date>
    </item>
  </channel>
</rss>

