<?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: Comparing fields with previous events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35368#M178450</link>
    <description>&lt;P&gt;SQL is an entirely different thing &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Using streamstats, you can start like this (untested, don't have splunk for android...):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;you base search | streamstats current=f window=1 global=f last(field1) as last_field1 by user | where field1!=last_field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The streamstats copies the last value into the current event, and the where only keeps those where the value has changed. For reference, take a look at &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats&lt;/A&gt; in case I mixed up some switch... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2013 17:46:02 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2013-05-16T17:46:02Z</dc:date>
    <item>
      <title>Comparing fields with previous events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35365#M178447</link>
      <description>&lt;P&gt;A logon script generates an event every time a user logs into the desktop. Here are the sample events in Splunk from those events -&lt;/P&gt;

&lt;P&gt;user_A;05/10/13 10:15:01 AM;field1="cat";field2="mouse"&lt;BR /&gt;
user_B;05/10/13 09:01:01 AM;field1="cat";field2="mouse"&lt;BR /&gt;
user_A;05/09/13 09:05:01 AM;field1="mouse";field2="horse"&lt;BR /&gt;
user_B;05/09/13 09:01:01 AM;field1="cat";field2="mouse"&lt;BR /&gt;
user_A;05/08/13 11:05:01 AM;field1="mouse";field2="horse"&lt;/P&gt;

&lt;P&gt;I want to be able to generate a report when "field1" changes per user, even compared to the last event. In this case I want a report that lists the event "user_A;05/10/13 10:15:01 AM;field1="cat";field2="mouse". Any help would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:54:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35365#M178447</guid>
      <dc:creator>sudhir_gandhe</dc:creator>
      <dc:date>2020-09-28T13:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields with previous events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35366#M178448</link>
      <description>&lt;P&gt;You could use streamstats to copy the previous field value into the current event by user, and then do the comparisons and filters you like.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 06:49:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35366#M178448</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-05-16T06:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields with previous events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35367#M178449</link>
      <description>&lt;P&gt;I am not really a SQL guys and havent used streamstats before. Can you help build me this query? Thanks for any help.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 17:21:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35367#M178449</guid>
      <dc:creator>sudhir_gandhe</dc:creator>
      <dc:date>2013-05-16T17:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields with previous events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35368#M178450</link>
      <description>&lt;P&gt;SQL is an entirely different thing &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Using streamstats, you can start like this (untested, don't have splunk for android...):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;you base search | streamstats current=f window=1 global=f last(field1) as last_field1 by user | where field1!=last_field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The streamstats copies the last value into the current event, and the where only keeps those where the value has changed. For reference, take a look at &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats&lt;/A&gt; in case I mixed up some switch... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 17:46:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35368#M178450</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-05-16T17:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields with previous events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35369#M178451</link>
      <description>&lt;P&gt;Perfect. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 15:36:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35369#M178451</guid>
      <dc:creator>sudhir_gandhe</dc:creator>
      <dc:date>2013-05-17T15:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing fields with previous events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35370#M178452</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I think i have got a similiar problem, which can hopefully be solved with this kind of search.&lt;/P&gt;

&lt;P&gt;I want to achieve a timechart, where the  count per day is about all unique users who have been active on that day &lt;STRONG&gt;and&lt;/STRONG&gt; the day before.&lt;/P&gt;

&lt;P&gt;For Instance:&lt;/P&gt;

&lt;P&gt;02.01.2013 - 2500      -&amp;gt; this means, that 2500 users have been active on 01.01.2013 and 02.01.013&lt;/P&gt;

&lt;P&gt;I'm not 100 % sure about the effects of the streamstats command, but after reading the posts above, my approach would be:&lt;/P&gt;

&lt;P&gt;sourcetype=A |bucket _time span=1d| dedup _time,user| sort _time&lt;BR /&gt;
| streamstats current=f window=1 global=f last(_time) as previous_time by user | eval returning_user=_time-previous_time | where returning_user="86400"|  timechart span=1d dc(user)&lt;/P&gt;

&lt;P&gt;Is this a correct adjustment to achieve my needed resultt with this kind of search?&lt;/P&gt;

&lt;P&gt;Best Regards&lt;/P&gt;

&lt;P&gt;Heinz&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:08:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-fields-with-previous-events/m-p/35370#M178452</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2020-09-28T15:08:28Z</dc:date>
    </item>
  </channel>
</rss>

