<?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 format a website/service downtime duration calculation results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502714#M139904</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval raw="01/10/2019 08:22 ABC_PORTAL 200
01/10/2019 08:24 ABC_PORTAL
01/10/2019 08:26 ABC_PORTAL
01/10/2019 08:28 ABC_PORTAL
01/10/2019 08:30 ABC_PORTAL
01/10/2019 08:32 ABC_PORTAL 503
01/10/2019 08:34 ABC_PORTAL 503
01/10/2019 08:36 ABC_PORTAL 503
01/10/2019 08:38 ABC_PORTAL 503
01/10/2019 08:40 ABC_PORTAL 200
01/10/2019 08:42 ABC_PORTAL 200
01/10/2019 08:44 ABC_PORTAL 200
01/10/2019 08:46 ABC_PORTAL 503
01/10/2019 08:48 ABC_PORTAL
01/10/2019 08:50 ABC_PORTAL
01/10/2019 08:52 ABC_PORTAL
01/10/2019 09:54 ABC_PORTAL
01/10/2019 09:56 ABC_PORTAL
01/10/2019 09:58 ABC_PORTAL 503
01/10/2019 10:00 ABC_PORTAL 503
01/10/2019 10:02 ABC_PORTAL 200
01/10/2019 10:04 ABC_PORTAL 200"
| makemv delim="
" raw
| mvexpand raw
| rex field=raw "(?&amp;lt;time&amp;gt;\d+/\d+/\d+ \d+:\d+) (?&amp;lt;title&amp;gt;\w+)"
| rex field=raw "(?&amp;lt;response_code&amp;gt;\d{3})$"
| eval _time=strptime(time,"%m/%d/%Y %H:%M")
| fillnull
| fields - time,- raw
| autoregress response_code as reg
| fillnull
| where reg!=response_code
| fields _time title response_code reg
| delta _time as duration
| autoregress _time as Downtime_start
| eval Downtime_end=_time
| where response_code!=200
| eval Duration = tostring(round(Downtime_end - Downtime_start),"duration")
| foreach Downtime_* 
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = strftime(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"%m/%d/%Y %H:%M")]
| fields title , Downtime_start,Downtime_end , Duration,response_code
| eval response_code=if(response_code==0,"slow_connection",response_code)
| fields - _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, How about this?&lt;/P&gt;</description>
    <pubDate>Tue, 22 Oct 2019 02:46:29 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2019-10-22T02:46:29Z</dc:date>
    <item>
      <title>How to format a website/service downtime duration calculation results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502710#M139900</link>
      <description>&lt;P&gt;Hi all, I have the below dataset for a website.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Time,title, response code &lt;BR /&gt;
01/10/2019 08:22    ABC_PORTAL  200&lt;BR /&gt;
01/10/2019 08:24    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 08:26    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 08:28    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 08:30    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 08:32    ABC_PORTAL  503&lt;BR /&gt;
01/10/2019 08:34    ABC_PORTAL  503&lt;BR /&gt;
01/10/2019 08:36    ABC_PORTAL  503&lt;BR /&gt;
01/10/2019 08:38    ABC_PORTAL  503&lt;BR /&gt;
01/10/2019 08:40    ABC_PORTAL  200&lt;BR /&gt;
01/10/2019 08:42    ABC_PORTAL  200&lt;BR /&gt;
01/10/2019 08:44    ABC_PORTAL  200&lt;BR /&gt;
01/10/2019 08:46    ABC_PORTAL  503&lt;BR /&gt;
01/10/2019 08:48    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 08:50    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 08:52    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 09:54    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 09:56    ABC_PORTAL&lt;BR /&gt;&lt;BR /&gt;
01/10/2019 09:58    ABC_PORTAL  503&lt;BR /&gt;
01/10/2019 10:00    ABC_PORTAL  503&lt;BR /&gt;
01/10/2019 10:02    ABC_PORTAL  200&lt;BR /&gt;
01/10/2019 10:04    ABC_PORTAL  200&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;In the above data the blank response code are connection timed out &lt;BR /&gt;
I want to show the downtime duration of the website.&lt;BR /&gt;
Below is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=| eval response_code=if(response_code="", "failed", response_code)
 | transaction title startswith="response_code=failed"  endswith="response_code=200" 
 |eval minutes=(duration/60)| stats sum(minutes) as "Total Downtime in minutes" by title,_time 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=| eval response_code=if(response_code="", "failed", response_code)
 | transaction title startswith="response_code=503"  endswith="response_code=200" 
 |eval minutes=(duration/60)| stats sum(minutes) as "Total Downtime in minutes" by title,_time 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is it is not calculating the correct duration I want to show the data in below manner&lt;BR /&gt;
title , Downtime_start,Downtime_end , Duration,response_code&lt;/P&gt;

&lt;P&gt;How can I achieve the above result or should I think of another way of representation any suggestions would be a great help!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:34:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502710#M139900</guid>
      <dc:creator>venky1544</dc:creator>
      <dc:date>2020-09-30T02:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a website/service downtime duration calculation results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502711#M139901</link>
      <description>&lt;P&gt;can you elaborate?&lt;BR /&gt;
according to your data, you had downtime due to something (no value) between 8:24 to 8:30 and then you had another downtime due to 503 error code, until 8:38 how do you want that reported?&lt;BR /&gt;
is it 14 minutes for the "something" and 8 minutes for 503? is it 6 and 8? 0 and 14?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 16:18:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502711#M139901</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-10-17T16:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a website/service downtime duration calculation results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502712#M139902</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; sourcetype=
 | eval startTime=if(response_code=503,_time,null())
 | eval endTime=if(response_code=200,_time,null())
 | stats min(startTime) as startTime max(endTime) as endTime by  Some_request_ID 
 | eval duration=endTime-startTime 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When you have large data transaction will take more resources and not accurate, try using an alternative.&lt;BR /&gt;
Hope this helps, Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 21:04:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502712#M139902</guid>
      <dc:creator>sandeepmakkena</dc:creator>
      <dc:date>2019-10-17T21:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a website/service downtime duration calculation results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502713#M139903</link>
      <description>&lt;P&gt;HI Adonio&lt;BR /&gt;
I'm still figuring out the best representation for this data the blank values are when there is a connection timed out.&lt;BR /&gt;
expectated output:- &lt;BR /&gt;
title , Downtime_start,Downtime_end , Duration,response_code&lt;BR /&gt;
ABC_PORTAL ,01/10/2019,01/10/2019 08:30,slow_connection&lt;BR /&gt;
ABC_PORTAL,01/10/2019 08:32,01/10/2019 08:40,503&lt;BR /&gt;
ABC_PORTAL,01/10/2019 08:46 ,01/10/2019 10:02 ,503&lt;/P&gt;

&lt;P&gt;not sure if this would be a correct representation&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:34:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502713#M139903</guid>
      <dc:creator>venky1544</dc:creator>
      <dc:date>2020-09-30T02:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a website/service downtime duration calculation results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502714#M139904</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval raw="01/10/2019 08:22 ABC_PORTAL 200
01/10/2019 08:24 ABC_PORTAL
01/10/2019 08:26 ABC_PORTAL
01/10/2019 08:28 ABC_PORTAL
01/10/2019 08:30 ABC_PORTAL
01/10/2019 08:32 ABC_PORTAL 503
01/10/2019 08:34 ABC_PORTAL 503
01/10/2019 08:36 ABC_PORTAL 503
01/10/2019 08:38 ABC_PORTAL 503
01/10/2019 08:40 ABC_PORTAL 200
01/10/2019 08:42 ABC_PORTAL 200
01/10/2019 08:44 ABC_PORTAL 200
01/10/2019 08:46 ABC_PORTAL 503
01/10/2019 08:48 ABC_PORTAL
01/10/2019 08:50 ABC_PORTAL
01/10/2019 08:52 ABC_PORTAL
01/10/2019 09:54 ABC_PORTAL
01/10/2019 09:56 ABC_PORTAL
01/10/2019 09:58 ABC_PORTAL 503
01/10/2019 10:00 ABC_PORTAL 503
01/10/2019 10:02 ABC_PORTAL 200
01/10/2019 10:04 ABC_PORTAL 200"
| makemv delim="
" raw
| mvexpand raw
| rex field=raw "(?&amp;lt;time&amp;gt;\d+/\d+/\d+ \d+:\d+) (?&amp;lt;title&amp;gt;\w+)"
| rex field=raw "(?&amp;lt;response_code&amp;gt;\d{3})$"
| eval _time=strptime(time,"%m/%d/%Y %H:%M")
| fillnull
| fields - time,- raw
| autoregress response_code as reg
| fillnull
| where reg!=response_code
| fields _time title response_code reg
| delta _time as duration
| autoregress _time as Downtime_start
| eval Downtime_end=_time
| where response_code!=200
| eval Duration = tostring(round(Downtime_end - Downtime_start),"duration")
| foreach Downtime_* 
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = strftime(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"%m/%d/%Y %H:%M")]
| fields title , Downtime_start,Downtime_end , Duration,response_code
| eval response_code=if(response_code==0,"slow_connection",response_code)
| fields - _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, How about this?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 02:46:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-format-a-website-service-downtime-duration-calculation/m-p/502714#M139904</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-10-22T02:46:29Z</dc:date>
    </item>
  </channel>
</rss>

