<?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 loop through the record to get the diff between them in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/575005#M200375</link>
    <description>&lt;P&gt;Hi ITWhisperer,&lt;/P&gt;&lt;P&gt;Not sure why after I copy again and paste it to the search engine.&lt;/P&gt;&lt;P&gt;It is working as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Nov 2021 08:34:06 GMT</pubDate>
    <dc:creator>zhanweiw</dc:creator>
    <dc:date>2021-11-16T08:34:06Z</dc:date>
    <item>
      <title>How to loop through the record to get the diff between them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574970#M200359</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I am trying to diff the new version against the one version older record and extract the diff from them.&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;ver 1.3 against 1.2 and ver 1.2 against 1.1 to only extract the diff between them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope to do it in a flexible ways as in future I may have ver 1.4 and so on...&lt;/P&gt;&lt;P&gt;I also want to limit the results to only latest 5 version diff.&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;I got 1.1, 1.2, ..., 1.10 version, but I only want the result for 1.6, 1.7, ..., 1.10 when diff against the previous one version.&lt;/P&gt;&lt;P&gt;Is that possible?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I have data like this:&lt;/P&gt;&lt;P&gt;records:&lt;/P&gt;&lt;P&gt;============================================&lt;/P&gt;&lt;P&gt;index=a, ver=1.1, a="halo", b="haha", c="nana"&lt;/P&gt;&lt;P&gt;index=a, ver=1.1, a="testing", b="haha", c="nana"&lt;/P&gt;&lt;P&gt;index=a, ver=1.1, a="halo", b="kaka", c="testing"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=a, ver=1.2, a="halo", b="haha", c="nana"&lt;/P&gt;&lt;P&gt;index=a, ver=1.2, a="lala", b="haha", c="nana"&lt;/P&gt;&lt;P&gt;index=a, ver=1.2, a="halo", b="kaka", c="TESTING"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=a, ver=1.3, a="halo", b="haha", c="nana"&lt;/P&gt;&lt;P&gt;index=a, ver=1.3, a="lala", b="haha", c="tata"&lt;/P&gt;&lt;P&gt;index=a, ver=1.3, a="halo", b="kaka", c="lala"&lt;/P&gt;&lt;P&gt;index=a, ver=1.3, a="halo", b="kaka", c="kakaka"&lt;/P&gt;&lt;P&gt;============================================&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result expected when comparing ver 1.2 against 1.1 and ver1.3 against 1.2:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;ver&lt;/TD&gt;&lt;TD width="25%"&gt;added record (merging a b c using ",")&lt;/TD&gt;&lt;TD width="25%"&gt;removed record&amp;nbsp;(merging a b c using ",")&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;1.2&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;P&gt;lala,haha,nana&lt;/P&gt;&lt;P&gt;halo,kaka,TESTING&lt;/P&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;P&gt;testing,haha,nana&lt;/P&gt;&lt;P&gt;halo,kaka,testing&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;1.3&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;P&gt;lala,haha,tata&lt;/P&gt;&lt;P&gt;halo,kaka,lala&lt;/P&gt;&lt;P&gt;halo,kaka,kakaka&lt;/P&gt;&lt;/TD&gt;&lt;TD width="25%"&gt;&lt;P&gt;lala,haha,nana&lt;/P&gt;&lt;P&gt;halo,kaka,TESTING&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 07:20:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574970#M200359</guid>
      <dc:creator>zhanweiw</dc:creator>
      <dc:date>2021-11-16T07:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through the record to get the diff between them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574993#M200368</link>
      <description>&lt;P&gt;Are these separate events in splunk?&lt;/P&gt;&lt;P&gt;You seem to be comparing the first event in version 1.1 with the first event in version 1.2, and the second event in version 1.1 with the second event in version 1.2, and so on. Is this correct? Is there some other way to identify which events should be compared against each other?&lt;/P&gt;&lt;P&gt;Why does&amp;nbsp;&lt;SPAN&gt;lala, haha, tata not feature as an addition in version 1.3 since it doesn't appear in version 1.2?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 07:15:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574993#M200368</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-11-16T07:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through the record to get the diff between them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574996#M200370</link>
      <description>&lt;P&gt;Thanks for pointing out, I have updated the post.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You seem to be comparing the first event in version 1.1 with the first event in version 1.2, and the second event in version 1.1 with the second event in version 1.2, and so on. Is this correct?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Ya, I am comparing version 1.2 against 1.1 then 1.3 against 1.2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there some other way to identify which events should be compared against each other?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;No other way. Not sure is it possible to use mvindex to get list of uniq version then do zipping like below and compare against each other.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[(1.2, 1.1)&lt;BR /&gt;&amp;nbsp;(1.3, 1.2)]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 07:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574996#M200370</guid>
      <dc:creator>zhanweiw</dc:creator>
      <dc:date>2021-11-16T07:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through the record to get the diff between them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574999#M200371</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="index=a, ver=1.1, a=\"halo\", b=\"haha\", c=\"nana\"

index=a, ver=1.1, a=\"testing\", b=\"haha\", c=\"nana\"

index=a, ver=1.1, a=\"halo\", b=\"kaka\", c=\"testing\"

index=a, ver=1.2, a=\"halo\", b=\"haha\", c=\"nana\"

index=a, ver=1.2, a=\"lala\", b=\"haha\", c=\"nana\"

index=a, ver=1.2, a=\"halo\", b=\"kaka\", c=\"TESTING\"

index=a, ver=1.3, a=\"halo\", b=\"haha\", c=\"nana\"

index=a, ver=1.3, a=\"lala\", b=\"haha\", c=\"tata\"

index=a, ver=1.3, a=\"halo\", b=\"kaka\", c=\"lala\"

index=a, ver=1.3, a=\"halo\", b=\"kaka\", c=\"kakaka\""
| multikv noheader=t
| table _raw



| kv
| streamstats count as row by ver
| sort 0 row ver
| streamstats list(a) as previous_a list(b) as previous_b list(c) as previous_c window=1 current=f by row
| where ver!="1.1"
| where a!=previous_a OR b!=previous_b OR c!=previous_c OR isnull(previous_a) OR isnull(previous_b) OR isnull(previous_c)
| sort 0 ver row
| eval added=a.",".b.",".c
| eval removed=previous_a.",".previous_b.",".previous_c
| stats list(added) as added list(removed) as removed by ver&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Nov 2021 07:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/574999#M200371</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-11-16T07:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through the record to get the diff between them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/575001#M200372</link>
      <description>&lt;P&gt;Hi ITWhisperer,&lt;/P&gt;&lt;P&gt;Thanks for your respond but not sure why the result is empty after I run it.&lt;/P&gt;&lt;P&gt;Can you help to confirm?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 08:07:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/575001#M200372</guid>
      <dc:creator>zhanweiw</dc:creator>
      <dc:date>2021-11-16T08:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through the record to get the diff between them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/575003#M200373</link>
      <description>&lt;P&gt;Here is a screenshot of it working&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITWhisperer_0-1637050944542.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/16869i71AC070E58595C9F/image-size/large?v=v2&amp;amp;px=999" role="button" title="ITWhisperer_0-1637050944542.png" alt="ITWhisperer_0-1637050944542.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What are you doing differently?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 08:23:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/575003#M200373</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-11-16T08:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through the record to get the diff between them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/575005#M200375</link>
      <description>&lt;P&gt;Hi ITWhisperer,&lt;/P&gt;&lt;P&gt;Not sure why after I copy again and paste it to the search engine.&lt;/P&gt;&lt;P&gt;It is working as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 08:34:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-loop-through-the-record-to-get-the-diff-between-them/m-p/575005#M200375</guid>
      <dc:creator>zhanweiw</dc:creator>
      <dc:date>2021-11-16T08:34:06Z</dc:date>
    </item>
  </channel>
</rss>

