<?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 How can I compare mvfields and get a diff? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318022#M4391</link>
    <description>&lt;P&gt;All, &lt;/P&gt;

&lt;P&gt;I just had a user want to compare lists/arrays for diff etc. Honestly I have no idea how I might compare mvfields or even events. Wondering if you can point me to a good tutorial/doc on this? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SOME USER [2:10 PM] 
----


[2:10] 
does Splunk have any way to compare lists/arrays?


[2:11] 
I have delimited list A and list B


[2:11] 
is there a splunk function to diff the two?


[2:11] 
(or alternatively, split list A and list B, load them into two mvindex-ed fields, and compare the two fields for diffs)


[2:12] 
My Use Case:  Windows logs changes to AD Group memberships, but doesn't actually tell you WAHT change was made


[2:13] 
so I want to compare Event 1 "Here are the current group members" to Event 2's "Here are the current group members" and find what changed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Sep 2017 17:36:54 GMT</pubDate>
    <dc:creator>daniel333</dc:creator>
    <dc:date>2017-09-05T17:36:54Z</dc:date>
    <item>
      <title>How can I compare mvfields and get a diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318022#M4391</link>
      <description>&lt;P&gt;All, &lt;/P&gt;

&lt;P&gt;I just had a user want to compare lists/arrays for diff etc. Honestly I have no idea how I might compare mvfields or even events. Wondering if you can point me to a good tutorial/doc on this? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SOME USER [2:10 PM] 
----


[2:10] 
does Splunk have any way to compare lists/arrays?


[2:11] 
I have delimited list A and list B


[2:11] 
is there a splunk function to diff the two?


[2:11] 
(or alternatively, split list A and list B, load them into two mvindex-ed fields, and compare the two fields for diffs)


[2:12] 
My Use Case:  Windows logs changes to AD Group memberships, but doesn't actually tell you WAHT change was made


[2:13] 
so I want to compare Event 1 "Here are the current group members" to Event 2's "Here are the current group members" and find what changed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 17:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318022#M4391</guid>
      <dc:creator>daniel333</dc:creator>
      <dc:date>2017-09-05T17:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare mvfields and get a diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318023#M4392</link>
      <description>&lt;P&gt;Okay, first, &lt;CODE&gt;set diff&lt;/CODE&gt; is clunky and I haven't found a good use case for it.  There are much easier ways to compare things.&lt;/P&gt;

&lt;P&gt;Let's just do the basic straightforward approach.  put the first set in with some field marked "A" and the second set in with some field marked "B".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    | inputcsv append=t mylistA.csv | table user group | eval myfield="A"
    | append [ | inputcsv append=t mylistA.csv | table user group | eval myfield="B"]
    | stats values(myfield) as myfield by user group
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives you records which have three fields, user, group and myfield.  myfield is a multivalue field, and if it has mvcount(myfield)&amp;gt;1 then it is in both files unchanged.  If you just want to see changes then do this.... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | where mvcount(myfield)=1
   | eval mystatus = if(myfield="A","removed", "added")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 18:01:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318023#M4392</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-05T18:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare mvfields and get a diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318024#M4393</link>
      <description>&lt;P&gt;Wow, this one was SUPER fun!  Feast your eyes on this @alacercogitatus:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval raw="a,b,c,d,e a,b,c,e,f"
| makemv raw
| mvexpand raw
| makemv delim="," raw
| eval host="matchingHost"
| streamstats count AS _serial
| eval after=if(_serial=1, raw, null())
| eval before=if(_serial=2, raw, null())
| fields - raw

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| selfjoin _time host
| streamstats count AS _serial
| multireport
    [| mvexpand after
    | where before!=after
    | rename after AS removed]
    [| mvexpand before
    | where before!=after
    | rename before AS added]
| fields - before after
| stats first(_time) AS _time first(host) AS host values(*) AS * BY _serial
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As long as the pairs of events have the same exact timestamp, this works for any number of hosts and pairs.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 03:04:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318024#M4393</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-06T03:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare mvfields and get a diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318025#M4394</link>
      <description>&lt;P&gt;@daniel333 You should pick the bestest answer and click Accept to close this question (and UpVote any good/useful answers).&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jun 2018 21:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318025#M4394</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-06-30T21:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare mvfields and get a diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318026#M4395</link>
      <description>&lt;P&gt;If one of these worked, @daniel333, then you should come back and click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question and help others.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 20:22:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/318026#M4395</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-12T20:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare mvfields and get a diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/553335#M4396</link>
      <description>&lt;P&gt;This was much easier for me:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;eval diff=mvmap(field1,if(isnull(mvfind(field2,field1)),field1,null))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 14:49:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/553335#M4396</guid>
      <dc:creator>RobertEikel</dc:creator>
      <dc:date>2021-05-27T14:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare mvfields and get a diff?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/623747#M10864</link>
      <description />
      <pubDate>Thu, 08 Dec 2022 18:12:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-compare-mvfields-and-get-a-diff/m-p/623747#M10864</guid>
      <dc:creator>sureshmurgan</dc:creator>
      <dc:date>2022-12-08T18:12:24Z</dc:date>
    </item>
  </channel>
</rss>

