<?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 combine continuous values within 5 minutes? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367947#M165238</link>
    <description>&lt;P&gt;Hi syokota [Splunk],&lt;BR /&gt;
please detail more you answer first Final Result or second one?&lt;BR /&gt;
in the first case&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| stats values(No) As No earliest(_time) AS _time values(delta_value) AS delta_value BY value1 
| table No  _time value1 delta_value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the second case&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| stats values(No) As No earliest(_time) AS _time values(delta_value) AS delta_value count BY value1 
| where count=1
| table No  _time value1 delta_value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2017 10:56:05 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-11-13T10:56:05Z</dc:date>
    <item>
      <title>How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367946#M165237</link>
      <description>&lt;P&gt;Hi Experts,&lt;BR /&gt;
I'd like to filter the record when the "delta_value" has the same value within 15 seconds (or repeats 3 times).&lt;/P&gt;

&lt;P&gt;The sample value is below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;No, _time, value1, delta_value
1, 05/26/2017 06:32:50, 5.949602127, 0
2, 05/26/2017 06:32:55, 15.949602127, 10
3, 05/26/2017 06:33:00, 16.949602127, 1
4, 05/26/2017 06:33:05, 17.949602127, 1
5, 05/26/2017 06:33:10, 18.949602127, 1
6, 05/26/2017 06:33:15, 17.949602127, 1
7, 05/26/2017 06:33:20, 17.949602127, 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I wish to finalize below search outputs.&lt;/P&gt;

&lt;P&gt;Ideal Final Result pattern A.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;No, _time, value1, delta_value
1, 05/26/2017 06:32:50, 5.949602127, 0
2, 05/26/2017 06:32:55, 15.949602127, 10
3, 05/26/2017 06:33:00, 16.949602127, 1
7, 05/26/2017 06:33:20, 17.949602127, 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;P&gt;Ideal Final Result pattern B &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;No, _time, value1, delta_value
1, 05/26/2017 06:32:50, 5.949602127, 0
2, 05/26/2017 06:32:55, 15.949602127, 10
7, 05/26/2017 06:33:20, 17.949602127, 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do you do it? Any comments and any idea welcome!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 10:19:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367946#M165237</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-13T10:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367947#M165238</link>
      <description>&lt;P&gt;Hi syokota [Splunk],&lt;BR /&gt;
please detail more you answer first Final Result or second one?&lt;BR /&gt;
in the first case&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| stats values(No) As No earliest(_time) AS _time values(delta_value) AS delta_value BY value1 
| table No  _time value1 delta_value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the second case&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| stats values(No) As No earliest(_time) AS _time values(delta_value) AS delta_value count BY value1 
| where count=1
| table No  _time value1 delta_value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 10:56:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367947#M165238</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-13T10:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367948#M165239</link>
      <description>&lt;P&gt;Sorry to bothering you.&lt;BR /&gt;
The fields of “No” is not existing in both actual raw log and ideal final results.&lt;/P&gt;

&lt;P&gt;Please ignore the No column.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:06:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367948#M165239</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-13T11:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367949#M165240</link>
      <description>&lt;P&gt;without the &lt;CODE&gt;No&lt;/CODE&gt; column in table command and &lt;CODE&gt;values(No) As No&lt;/CODE&gt; in stats command, does it run?&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367949#M165240</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-13T11:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367950#M165241</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/73924"&gt;@syokota_splunk&lt;/a&gt;, I was able to create query to generate sample pattern A, where same delta_value if repeated for more than 2 times will all be merged as one row. Please try out run anywhere search below, which is based on &lt;CODE&gt;streamstats&lt;/CODE&gt; which requires events to be sorted with time i.e. ascending or descending (your sample data seemed sorted chronologically which suffices the need)&lt;BR /&gt;
PS: Commands till &lt;CODE&gt;| table&lt;/CODE&gt; generate mock data as per the question. Only continuous delta_values increase counter, if there is a different value the counter resets.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="1,05/26/2017 06:32:50,5.949602127,0;2,05/26/2017 06:32:55,15.949602127,10;3,05/26/2017 06:33:00,16.949602127,1;4,05/26/2017 06:33:05,17.949602127,1;5,05/26/2017 06:33:10,18.949602127,1;6,05/26/2017 06:33:15,17.949602127,1;7,05/26/2017 06:33:20,17.949602127,0;8,05/26/2017 06:33:40,13.889602127,0" 
| makemv data delim=";" 
| mvexpand data 
| eval data=split(data,",") 
| eval No=mvindex(data,0), _time=mvindex(data,1), value1=mvindex(data,2), delta_value=mvindex(data,3) 
| table No _time value1 delta_value 
| eval _time=strptime(_time,"%m/%d/%Y %H:%M:%S") 
| streamstats count as sameCount by delta_value reset_on_change=true
| eventstats max(sameCount) as maxCounter by delta_value
| eval maxCounter=case(sameCount=1 AND maxCounter&amp;gt;2,1,true(),maxCounter)
| search maxCounter=1 OR maxCounter=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your second pattern is a bit complicated. I will give that a try, but hopefully someone will be able to solve before that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:46:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367950#M165241</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T16:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367951#M165242</link>
      <description>&lt;P&gt;Actually the "No" column is not existing. Please refer below raw data.&lt;/P&gt;

&lt;P&gt;_time, value1, delta_value&lt;BR /&gt;
05/26/2017 06:32:50, 5.949602127, 0&lt;BR /&gt;
05/26/2017 06:32:55, 15.949602127, 10&lt;BR /&gt;
05/26/2017 06:33:00, 16.949602127, 1&lt;BR /&gt;
05/26/2017 06:33:05, 17.949602127, 1&lt;BR /&gt;
05/26/2017 06:33:10, 18.949602127, 1&lt;BR /&gt;
05/26/2017 06:33:15, 17.949602127, 1&lt;BR /&gt;
05/26/2017 06:33:20, 17.949602127, 0&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:46:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367951#M165242</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2020-09-29T16:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367952#M165243</link>
      <description>&lt;P&gt;Thank you niketnilay!&lt;BR /&gt;
But I'm sorry, the "No" column is not existing in raw log that's my fault..&lt;/P&gt;

&lt;P&gt;And "_time" is dynamically changing I mean not only sample data also new data will come, so you mentioned SPL of no.2 raw is difficult to do it.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 22:00:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367952#M165243</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-13T22:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367953#M165244</link>
      <description>&lt;P&gt;You could try something like this &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=xxx sourcetype=xxx | bin delta_value span=15s | timechart cont=true count&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;You could also look into the &lt;CODE&gt;| makecontineous&lt;/CODE&gt; command &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/ListOfSearchCommands"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/ListOfSearchCommands&lt;/A&gt;&lt;BR /&gt;
"Makes a field that is supposed to be the x-axis continuous (invoked by chart/timechart)"&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 22:05:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367953#M165244</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2017-11-13T22:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367954#M165245</link>
      <description>&lt;P&gt;@syokota, I have extracted &lt;CODE&gt;No&lt;/CODE&gt; field but have not used it in any logic.&lt;/P&gt;

&lt;P&gt;And what I meant by events sorted by time (in chornologica or reverse), is that you would need to use &lt;CODE&gt;sort&lt;/CODE&gt; or &lt;CODE&gt;reverse&lt;/CODE&gt; command before using streamstats as it generates the stats on streaming manner and unsorted events may give incorrect stats.&lt;/P&gt;

&lt;P&gt;My commands till &lt;CODE&gt;| table&lt;/CODE&gt; just created the dummy table as per the data provided in the question. You would need to create your base query in a way that. Your output is sorted by _time (even if it does not have &lt;CODE&gt;No&lt;/CODE&gt; field that would be fine).&lt;/P&gt;

&lt;P&gt;If your default output table is in reverse chronological order then streamstats might need adjustment (not sure). But will perform better because one additional &lt;CODE&gt;| reverse&lt;/CODE&gt; command can be avoided before streamstats. Please do try out and confirm. If it does not work give the sample output from your base search which displays &lt;CODE&gt;_time, value1, delta_value&lt;/CODE&gt;, in the same order.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 04:42:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367954#M165245</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-14T04:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367955#M165246</link>
      <description>&lt;P&gt;Did this work for you?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 14:57:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367955#M165246</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2017-11-27T14:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine continuous values within 5 minutes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367956#M165247</link>
      <description>&lt;P&gt;I've done with below SPL.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sensor"
| sort + _time
| streamstats current=f window=1 last(value1) as last_value1
| eval diff=abs(value1-last_value1),diff=if(diff&amp;gt;180,abs(value1+last_value1-360),diff)
| streamstats current=t window=50 values(diff) as last_diff_50
| eval countmv=mvcount(last_diff_50)
| search countmv!=1
| table _time  value1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Nov 2017 20:19:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-continuous-values-within-5-minutes/m-p/367956#M165247</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-27T20:19:43Z</dc:date>
    </item>
  </channel>
</rss>

