<?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 events with counting? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/556317#M157977</link>
    <description>&lt;P&gt;I'm sorry if my question was not complete. The fact is that initially, I do not have an X field, I create it using | eval field_x = if(fieldValue &amp;gt;= fieldThreshold, 1, 0).&lt;/P&gt;</description>
    <pubDate>Fri, 18 Jun 2021 09:14:15 GMT</pubDate>
    <dc:creator>rendie</dc:creator>
    <dc:date>2021-06-18T09:14:15Z</dc:date>
    <item>
      <title>How to combine events with counting?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/555952#M157864</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;Just a quick question. For example, a have a dataset&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;_time&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;field_x&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;field_y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;14:01&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;14:02&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;14:03&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;14:04&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;14:05&lt;/TD&gt;&lt;TD height="25px"&gt;1&lt;/TD&gt;&lt;TD height="25px"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;14:06&lt;/TD&gt;&lt;TD height="25px"&gt;0&lt;/TD&gt;&lt;TD height="25px"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;14:07&lt;/TD&gt;&lt;TD height="25px"&gt;1&lt;/TD&gt;&lt;TD height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;14:08&lt;/TD&gt;&lt;TD height="25px"&gt;1&lt;/TD&gt;&lt;TD height="25px"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If describe this logic in text:&amp;nbsp;field_x is a random number 0 or 1.&amp;nbsp;field_y is how many 0 was in previous events for&amp;nbsp;field_x.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 11:25:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/555952#M157864</guid>
      <dc:creator>rendie</dc:creator>
      <dc:date>2021-06-16T11:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine events with counting?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/555971#M157867</link>
      <description>&lt;P&gt;I changed field_x to As and Bs to show that non-numerics can be dealt with, you just need to compare to one of the values. I recreated field_y and field_z so you can see the process matches your requirement.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="_time	field_x	field_y
14:01	A	0
14:02	A	1
14:03	A	2
14:04	B	3
14:05	B	0
14:06	A	0
14:07	B	1
14:08	B	0"
| multikv forceheader=1
| fields - _* linecount
| streamstats window=1 current=f values(field_x) as previous
| eval previous_match=if(previous="A",1,0)
| streamstats window=1 current=f values(previous_match) as previous
| eval groupstart=if(previous_match=1 AND previous=0,1,0)
| streamstats sum(groupstart) as group
| eval group=if(previous_match=1,group,null)
| streamstats sum(previous_match) as field_z by group
| fillnull value=0 field_z&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 13:04:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/555971#M157867</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-16T13:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine events with counting?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/556030#M157878</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/209705"&gt;@rendie&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH | sort _time | table _time field_x 
| autoregress field_x as pre p=1 | eval A=if(pre=0,1,null()) | accum A | streamstats list(A) as Z | eval AA = if(isnull(A) and mvcount(Z)&amp;gt;0,mvcount(Z),null()) | filldown AA | fillnull value="0" AA | eval field_y=A-AA
| table _time field_x field_y&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="_time	field_x	
14:01	0	0
14:02	0	1
14:03	0	2
14:04	1	3
14:05	1	0
14:06	0	0
14:07	0	1
14:08	1	0
14:09	0	0
14:10	1	0
14:11	0	0
14:12	0	0
14:13	0	0
14:14	0	0
14:15	1	0
14:16	0	0
14:17	0	0
14:18	1	0
" 
| multikv forceheader=1 
| eval t = 100 | accum t | eval _time = _time + t | sort _time | table _time field_x 
| autoregress field_x as pre p=1 | eval A=if(pre=0,1,null()) | accum A | streamstats list(A) as Z | eval AA = if(isnull(A) and mvcount(Z)&amp;gt;0,mvcount(Z),null()) | filldown AA | fillnull value="0" AA | eval field_y=A-AA
| table _time field_x field_y&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 17:57:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/556030#M157878</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-06-16T17:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine events with counting?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/556316#M157976</link>
      <description>&lt;P&gt;I'm sorry if my question was not complete. The fact is that initially, I do not have an X field, I create it using | eval field_x = if(fieldValue &amp;gt;= fieldThreshold, 1, 0)&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 09:13:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/556316#M157976</guid>
      <dc:creator>rendie</dc:creator>
      <dc:date>2021-06-18T09:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine events with counting?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/556317#M157977</link>
      <description>&lt;P&gt;I'm sorry if my question was not complete. The fact is that initially, I do not have an X field, I create it using | eval field_x = if(fieldValue &amp;gt;= fieldThreshold, 1, 0).&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 09:14:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-events-with-counting/m-p/556317#M157977</guid>
      <dc:creator>rendie</dc:creator>
      <dc:date>2021-06-18T09:14:15Z</dc:date>
    </item>
  </channel>
</rss>

