<?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 do you search to return a table of only fields that change between events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383737#M112081</link>
    <description>&lt;P&gt;Something like this aircode should work.  Test first on a very small amount of data, for example,  a few records each with two different keys.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  your search that gets the various records

 | rename COMMENT as "Sort into key and time order" 
 | sort 0 YourKeyFields  _time

 | rename COMMENT as "Rename the fields so they can be identified automatically" 
 | rename * as *_New

 | rename COMMENT as "Put the keys back where they are supposed to be" 
 | rename YourKeyFields_New as  YourKeyFIelds

 | rename COMMENT as "Copy the fields forward by key" 
 | streamstats current=f last(*_New) as *_Old by YourKeyFields

 | rename COMMENT as "Compare the fields and delete all that have not changed or are not present" 
 | foreach *_New [ 
      eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed = case( &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; == &amp;lt;&amp;lt;MATCHSTR&amp;gt;_Old,null(),  isnull( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old ), null(),  true() "Yep")
    | eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old = case( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed == "Yep", &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old )
    | eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_New = case( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed == "Yep", &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_New )
    ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After you've verified that the above does work, you can optionally add a line that deletes &lt;CODE&gt;*_Changed&lt;/CODE&gt; and/or a line that renames &lt;CODE&gt;*_New&lt;/CODE&gt; back to &lt;CODE&gt;*&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Updated to correct &lt;CODE&gt;&amp;lt;&amp;lt;MATCH&amp;gt;&amp;gt;&lt;/CODE&gt; to &lt;CODE&gt;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Sep 2018 22:25:16 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2018-09-17T22:25:16Z</dc:date>
    <item>
      <title>How do you search to return a table of only fields that change between events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383734#M112078</link>
      <description>&lt;P&gt;Lets say I have a query that returns all of the updates for a given bug ID.  This returns a result set for the specified ID with timestamps for when each modification took place on the bug&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=bugs id=123
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are one or more fields that can change during each update(event)&lt;/P&gt;

&lt;P&gt;I want a table that returns:  _time, field_modified, modified_value(diff from previous event)&lt;/P&gt;

&lt;P&gt;In the case of multiple fields changing in a single update, the output could be similar to using the stats(values) or list command.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:19:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383734#M112078</guid>
      <dc:creator>smahone11</dc:creator>
      <dc:date>2020-09-29T21:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search to return a table of only fields that change between events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383735#M112079</link>
      <description>&lt;P&gt;Can we have some sample events which shows how the changed values are logged? &lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 20:13:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383735#M112079</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-09-17T20:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search to return a table of only fields that change between events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383736#M112080</link>
      <description>&lt;P&gt;Well basically, its as easy as the following&lt;/P&gt;

&lt;P&gt;Taking the following event fields returned&lt;/P&gt;

&lt;P&gt;timestamp, id, priority, assigned, team, status&lt;/P&gt;

&lt;P&gt;(example return)&lt;/P&gt;

&lt;P&gt;9/17/2018 8:57:00, 524441, 1, triage, web, new&lt;BR /&gt;
9/17/2018 9:57:00, 524441, 1, tim, service, open&lt;BR /&gt;
9/17/2018 10:57:00, 524441, 2, tim, service, open&lt;BR /&gt;
9/17/2018 11:57:00, 524441, 2, tim, service, in_progress&lt;BR /&gt;
9/17/2018 12:57:00, 524441, 2, joe, service, closed&lt;/P&gt;

&lt;P&gt;I would like to display as&lt;/P&gt;

&lt;P&gt;_time, modified_field, new_value&lt;BR /&gt;
9/17/2018 9:57:00, id, 524441&lt;BR /&gt;
                                  priority, 1&lt;BR /&gt;
                                  assigned, triage&lt;BR /&gt;
                                  team, web&lt;BR /&gt;
                                  status, new&lt;BR /&gt;
9/17/2018 9:57:00, assigned, tim&lt;BR /&gt;
                                  team, service&lt;BR /&gt;
                                  status, open&lt;BR /&gt;
9/17/2018 10:57:00......etc.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:19:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383736#M112080</guid>
      <dc:creator>smahone11</dc:creator>
      <dc:date>2020-09-29T21:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search to return a table of only fields that change between events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383737#M112081</link>
      <description>&lt;P&gt;Something like this aircode should work.  Test first on a very small amount of data, for example,  a few records each with two different keys.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  your search that gets the various records

 | rename COMMENT as "Sort into key and time order" 
 | sort 0 YourKeyFields  _time

 | rename COMMENT as "Rename the fields so they can be identified automatically" 
 | rename * as *_New

 | rename COMMENT as "Put the keys back where they are supposed to be" 
 | rename YourKeyFields_New as  YourKeyFIelds

 | rename COMMENT as "Copy the fields forward by key" 
 | streamstats current=f last(*_New) as *_Old by YourKeyFields

 | rename COMMENT as "Compare the fields and delete all that have not changed or are not present" 
 | foreach *_New [ 
      eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed = case( &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; == &amp;lt;&amp;lt;MATCHSTR&amp;gt;_Old,null(),  isnull( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old ), null(),  true() "Yep")
    | eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old = case( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed == "Yep", &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old )
    | eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_New = case( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed == "Yep", &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_New )
    ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After you've verified that the above does work, you can optionally add a line that deletes &lt;CODE&gt;*_Changed&lt;/CODE&gt; and/or a line that renames &lt;CODE&gt;*_New&lt;/CODE&gt; back to &lt;CODE&gt;*&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Updated to correct &lt;CODE&gt;&amp;lt;&amp;lt;MATCH&amp;gt;&amp;gt;&lt;/CODE&gt; to &lt;CODE&gt;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 22:25:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383737#M112081</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-09-17T22:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search to return a table of only fields that change between events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383738#M112082</link>
      <description>&lt;P&gt;Thanks, however I am not sure how the following is supposed to work&lt;/P&gt;

&lt;P&gt;| rename COMMENT as "Put the keys back where they are supposed to be" &lt;BR /&gt;
  | rename YourKeyFIelds_New as  YourKeyFIelds&lt;/P&gt;

&lt;P&gt;| rename COMMENT as "Copy the fields forward by key" &lt;BR /&gt;
  | streamstats current=f last(*_New) as *_Old by YourKeyFIelds&lt;/P&gt;

&lt;P&gt;When I rename my fields  back, the streamstats has nothing to compare as there now are now no *New fields in the data.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:16:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383738#M112082</guid>
      <dc:creator>smahone11</dc:creator>
      <dc:date>2020-09-29T21:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search to return a table of only fields that change between events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383739#M112083</link>
      <description>&lt;P&gt;@smahone11 - &lt;/P&gt;

&lt;P&gt;Here's a run-anywhere sample that does what the code above was intended to do.&lt;/P&gt;

&lt;P&gt;As well, we've modified the code posted above to fix some minor syntax errors.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit action=add | head 10
  | rename COMMENT as "Sort into key and time order" 
  | sort 0 action  _time

  | table _time action date_s*

  | rename COMMENT as "Rename the fields so they can be identified automatically" 
  | rename * as *_New
  | rename COMMENT as "Put the keys back where they are supposed to be" 
  | rename action_New as  action
  | rename COMMENT as "Copy the fields forward by key" 
  | streamstats current=f last(*_New) as *_Old by action
  | rename COMMENT as "Compare the fields and delete all that have not changed or are not present" 
    | foreach *_New [ 
      eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed = case( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_New == &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old, null(),  isnull( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old ), null(),   true(),"yep")
    |  eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_New = case( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed == "yep", &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_New)
    |  eval &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old = case( &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Changed == "yep", &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_Old)
     ] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Sep 2018 00:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-to-return-a-table-of-only-fields-that-change/m-p/383739#M112083</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-09-18T00:39:01Z</dc:date>
    </item>
  </channel>
</rss>

