<?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 how many times a field value has changed for a stream of events over a period of time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167179#M47592</link>
    <description>&lt;P&gt;++&lt;BR /&gt;
And you could replace the ending &lt;CODE&gt;| table *&lt;/CODE&gt; by &lt;CODE&gt;|stats count as CountofChanges&lt;/CODE&gt; if you are interested only in the count.&lt;/P&gt;

&lt;P&gt;However, I am curious about the &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;and group it by a field called NetworkDeviceName.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;@jedatt01 Are you interested in finding how many times it has changed from/to each Node_Group?&lt;/P&gt;</description>
    <pubDate>Fri, 06 Mar 2015 03:22:55 GMT</pubDate>
    <dc:creator>ramdaspr</dc:creator>
    <dc:date>2015-03-06T03:22:55Z</dc:date>
    <item>
      <title>How to count how many times a field value has changed for a stream of events over a period of time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167177#M47590</link>
      <description>&lt;P&gt;I want to count the number of times the value of a field called "Node_Group" has changed for a stream of events over a period of time and group it by a field called NetworkDeviceName.&lt;/P&gt;

&lt;P&gt;I believe the streamstats command should accomplish this but I'm not confident in how to know when the change occurs. So far I just have | streamstats count(Node_Group) by NetworkDeviceName.&lt;/P&gt;

&lt;P&gt;Any ideas? &lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2015 16:46:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167177#M47590</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2015-03-02T16:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to count how many times a field value has changed for a stream of events over a period of time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167178#M47591</link>
      <description>&lt;P&gt;Yes, I believe &lt;CODE&gt;streamstats&lt;/CODE&gt; is the way to go. This command basically calculates stats for every event, based on the order the events are being returned in a search on Splunk... here an example, how you could use it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=bla "your search" fieldA=* | sort +_time
| streamstats window=1 current=false last(fieldA) AS previous_fieldA
| where fieldA!=last_fieldA | table *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that I've used &lt;CODE&gt;sort&lt;/CODE&gt; to guarantee the events are processed on the right order, from the oldest to the newest. After that I use &lt;CODE&gt;streamstats&lt;/CODE&gt; with the options &lt;CODE&gt;window=1 current=false&lt;/CODE&gt; to grab the previous value from &lt;STRONG&gt;fieldA&lt;/STRONG&gt; and &lt;EM&gt;"copy"&lt;/EM&gt; to the current event as &lt;STRONG&gt;previous_fieldA&lt;/STRONG&gt;. After that just make a search to see the ones which are different, so it'll indicate a change!&lt;/P&gt;

&lt;P&gt;Does that any sense for your use case? Let me know if we're getting close to what you're after.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2015 23:19:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167178#M47591</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2015-03-02T23:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to count how many times a field value has changed for a stream of events over a period of time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167179#M47592</link>
      <description>&lt;P&gt;++&lt;BR /&gt;
And you could replace the ending &lt;CODE&gt;| table *&lt;/CODE&gt; by &lt;CODE&gt;|stats count as CountofChanges&lt;/CODE&gt; if you are interested only in the count.&lt;/P&gt;

&lt;P&gt;However, I am curious about the &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;and group it by a field called NetworkDeviceName.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;@jedatt01 Are you interested in finding how many times it has changed from/to each Node_Group?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2015 03:22:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167179#M47592</guid>
      <dc:creator>ramdaspr</dc:creator>
      <dc:date>2015-03-06T03:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to count how many times a field value has changed for a stream of events over a period of time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167180#M47593</link>
      <description>&lt;P&gt;I'd try some variation of  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | sort _time NetworkDeviceName | streamstats dc(Node_Group) by NetworkDeviceName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Mar 2015 13:07:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167180#M47593</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-03-06T13:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to count how many times a field value has changed for a stream of events over a period of time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167181#M47594</link>
      <description>&lt;P&gt;Yes, trying to count the number of changes in field Node_Group because this implies a failover. Here's what did and it seems to be working correctly.&lt;/P&gt;

&lt;P&gt;streamstats window=2 dc(Node_Group) As NG_Count by NetworkDeviceName&lt;/P&gt;

&lt;P&gt;The window=2 is what solved it for me&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:07:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167181#M47594</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2020-09-28T19:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to count how many times a field value has changed for a stream of events over a period of time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167182#M47595</link>
      <description>&lt;P&gt;With a slight variation this worked......add window=2. thanks&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2015 14:02:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-how-many-times-a-field-value-has-changed-for-a/m-p/167182#M47595</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2015-03-06T14:02:30Z</dc:date>
    </item>
  </channel>
</rss>

