<?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: Calculate total continuous duration when value is equal or above static threshold with resetting calculation when it goes below in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468569#M131935</link>
    <description>&lt;P&gt;WOW! That was fast! Thank you!&lt;/P&gt;

&lt;P&gt;I only corrected &lt;CODE&gt;value&amp;gt;45&lt;/CODE&gt; to &lt;CODE&gt;value&amp;gt;=45&lt;/CODE&gt; and it is almost what I wanted to get.&lt;BR /&gt;
In you version duration is started to being calculated since the first value which crossed threshold (increasing direction). For that value I'd like to have &lt;CODE&gt;0&lt;/CODE&gt; and duration should be started to being calculated for next value (of course only if that next value is still equal or above threshold).&lt;/P&gt;

&lt;P&gt;Modified example:&lt;BR /&gt;
&lt;IMG src="https://i.imgur.com/8AaoxFH.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Result of your search:&lt;BR /&gt;
&lt;IMG src="https://i.imgur.com/yLOHVrO.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Is this even possible?&lt;/P&gt;</description>
    <pubDate>Sat, 04 Apr 2020 20:07:57 GMT</pubDate>
    <dc:creator>pawelzak</dc:creator>
    <dc:date>2020-04-04T20:07:57Z</dc:date>
    <item>
      <title>Calculate total continuous duration when value is equal or above static threshold with resetting calculation when it goes below</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468567#M131933</link>
      <description>&lt;P&gt;I have a log that contains numerical value which is logged irregularly:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8639i3DA8451FF559FFCC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I would like to calculate (and show on timechart) total continuous duration when value is equal or above static threshold. But I'd like to reset this calculation when it goes below that threshold.&lt;/P&gt;

&lt;P&gt;For threshold == 45 it should like this:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8640iF540944557180885/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How can I get this? Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Apr 2020 08:23:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468567#M131933</guid>
      <dc:creator>pawelzak</dc:creator>
      <dc:date>2020-04-04T08:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total continuous duration when value is equal or above static threshold with resetting calculation when it goes below</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468568#M131934</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="time,value
2020-03-31 22:00:00,40
2020-03-31 22:00:20,45
2020-03-31 22:01:03,46
2020-03-31 22:01:36,48
2020-03-31 22:02:01,52
2020-03-31 22:02:27,41
2020-03-31 22:03:11,43
2020-03-31 22:03:30,44
2020-03-31 22:04:08,48
2020-03-31 22:04:32,44
2020-03-31 22:05:01,46
2020-03-31 22:05:39,48
2020-03-31 22:06:00,52" 
| multikv forceheader=1 
| eval _time=strptime(time,"%F %T") 
| autoregress value as p_1 
| eval flag=if(value &amp;gt; 45 AND p_1 &amp;gt;= 45, 1, 0) 
| streamstats window=2 range(_time) as duration 
| streamstats reset_on_change=t sum(duration) as duration by flag 
| eval duration=if(flag=="0", "0", round(duration)) 
| table _time value duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;value&lt;/EM&gt; are changed from original question.&lt;BR /&gt;
&lt;EM&gt;flag&lt;/EM&gt; is the key. Please modify as you like.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Apr 2020 09:44:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468568#M131934</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-04T09:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total continuous duration when value is equal or above static threshold with resetting calculation when it goes below</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468569#M131935</link>
      <description>&lt;P&gt;WOW! That was fast! Thank you!&lt;/P&gt;

&lt;P&gt;I only corrected &lt;CODE&gt;value&amp;gt;45&lt;/CODE&gt; to &lt;CODE&gt;value&amp;gt;=45&lt;/CODE&gt; and it is almost what I wanted to get.&lt;BR /&gt;
In you version duration is started to being calculated since the first value which crossed threshold (increasing direction). For that value I'd like to have &lt;CODE&gt;0&lt;/CODE&gt; and duration should be started to being calculated for next value (of course only if that next value is still equal or above threshold).&lt;/P&gt;

&lt;P&gt;Modified example:&lt;BR /&gt;
&lt;IMG src="https://i.imgur.com/8AaoxFH.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Result of your search:&lt;BR /&gt;
&lt;IMG src="https://i.imgur.com/yLOHVrO.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Is this even possible?&lt;/P&gt;</description>
      <pubDate>Sat, 04 Apr 2020 20:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468569#M131935</guid>
      <dc:creator>pawelzak</dc:creator>
      <dc:date>2020-04-04T20:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total continuous duration when value is equal or above static threshold with resetting calculation when it goes below</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468570#M131936</link>
      <description>&lt;P&gt;yes, check my answer.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Apr 2020 21:21:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468570#M131936</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-04T21:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate total continuous duration when value is equal or above static threshold with resetting calculation when it goes below</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468571#M131937</link>
      <description>&lt;P&gt;This is exactly what I needed! &lt;/P&gt;

&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 10:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-total-continuous-duration-when-value-is-equal-or-above/m-p/468571#M131937</guid>
      <dc:creator>pawelzak</dc:creator>
      <dc:date>2020-04-07T10:24:00Z</dc:date>
    </item>
  </channel>
</rss>

