<?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 count Max Sub-sequence of identical numbers? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307992#M92424</link>
    <description>&lt;P&gt;I used the data you supplied in your example to populate a little table with a single row/field called &lt;CODE&gt;digit&lt;/CODE&gt;. If we didn't have to account for wrapping around the end of the list (the way you get to 7 in your example), it would be really straightforward. But here's a code snippet that achieves what you laid out:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval digit="0,0,0,0,0,1,0,1,1,0,0" 
| makemv delim="," digit 
| mvexpand digit 
| fields - _time 
| streamstats count BY digit reset_on_change=true 
| eventstats first(digit) AS first_digit, last(digit) AS last_digit 
| eventstats max(count) AS max_count BY digit 
| eventstats last(count) AS final_count 
| eval total_count=if(first_digit=last_digit AND first_digit=digit, max_count+final_count, max_count) 
| fields digit, total_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can adjust it for other digit lists by adjusting the second line - or customize it to match your data source by editing/removing the first five lines.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2018 15:19:42 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2018-02-26T15:19:42Z</dc:date>
    <item>
      <title>How to count Max Sub-sequence of identical numbers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307989#M92421</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;

&lt;P&gt;I need to calculate the maximum length of identical numbers &lt;BR /&gt;
for example : 0,0,0,0,0,1,0,1,1,0,0 and search for the sequence of 0, the result should be 7 in this case&lt;/P&gt;

&lt;P&gt;Anyone have any ideas how this could be accomplished?  &lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 13:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307989#M92421</guid>
      <dc:creator>avivn</dc:creator>
      <dc:date>2018-02-26T13:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to count Max Sub-sequence of identical numbers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307990#M92422</link>
      <description>&lt;P&gt;Can you give more examples to this? I can't see how you would get to 7 based on that data - maybe I'm missing something?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 14:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307990#M92422</guid>
      <dc:creator>bjoernhansen</dc:creator>
      <dc:date>2018-02-26T14:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to count Max Sub-sequence of identical numbers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307991#M92423</link>
      <description>&lt;P&gt;because i want to count the sequence of zeroes the sequence goes like this:&lt;/P&gt;

&lt;P&gt;the values:0,0,0,0,0,1,0,1,1,0,0,&lt;BR /&gt;
the result : 3,4,5,6,7,-, 1,- ,-,1,2&lt;/P&gt;

&lt;P&gt;the zeros at the start continues the zeroes at the end &lt;BR /&gt;
each value is in a different row same column&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 14:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307991#M92423</guid>
      <dc:creator>avivn</dc:creator>
      <dc:date>2018-02-26T14:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to count Max Sub-sequence of identical numbers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307992#M92424</link>
      <description>&lt;P&gt;I used the data you supplied in your example to populate a little table with a single row/field called &lt;CODE&gt;digit&lt;/CODE&gt;. If we didn't have to account for wrapping around the end of the list (the way you get to 7 in your example), it would be really straightforward. But here's a code snippet that achieves what you laid out:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval digit="0,0,0,0,0,1,0,1,1,0,0" 
| makemv delim="," digit 
| mvexpand digit 
| fields - _time 
| streamstats count BY digit reset_on_change=true 
| eventstats first(digit) AS first_digit, last(digit) AS last_digit 
| eventstats max(count) AS max_count BY digit 
| eventstats last(count) AS final_count 
| eval total_count=if(first_digit=last_digit AND first_digit=digit, max_count+final_count, max_count) 
| fields digit, total_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can adjust it for other digit lists by adjusting the second line - or customize it to match your data source by editing/removing the first five lines.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 15:19:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307992#M92424</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-02-26T15:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to count Max Sub-sequence of identical numbers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307993#M92425</link>
      <description>&lt;P&gt;thank you it works !&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 06:13:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-Max-Sub-sequence-of-identical-numbers/m-p/307993#M92425</guid>
      <dc:creator>avivn</dc:creator>
      <dc:date>2018-02-27T06:13:54Z</dc:date>
    </item>
  </channel>
</rss>

