<?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 2 results and showing difference in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-2-results-and-showing-difference/m-p/540496#M152916</link>
    <description>&lt;P&gt;Thanks.&amp;nbsp; I neglected to use "index OR index" as an an option.&amp;nbsp; I will definitely remove fields as the real data has a lot more data in it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Feb 2021 08:42:56 GMT</pubDate>
    <dc:creator>willadams</dc:creator>
    <dc:date>2021-02-19T08:42:56Z</dc:date>
    <item>
      <title>Comparing 2 results and showing difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-2-results-and-showing-difference/m-p/540478#M152913</link>
      <description>&lt;P&gt;My scenario is that I am trying to alert in the event where a user has been provided to an application &lt;STRONG&gt;but&lt;/STRONG&gt; that same user wasn't added to an Active Directory group .&amp;nbsp; So I have the following 2 indexes that provide me the information&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Application Access&amp;nbsp;&lt;/STRONG&gt;is in "index=myapp"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Active Directory&lt;/STRONG&gt; is in the "index=ad"&lt;/P&gt;&lt;P&gt;My search for a new user being given access to the application is something such as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myapp Operation=Creation user_object="user*@mydomain.com"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My search for a user being added to an Active Directory group is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=ad EventCode=4728 Group_Name="myapp_users"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the following searches that provide me with data but I can't figure out the next step to show where my objective is met (i.e. where the user didn't get added to the group but was given access to the app).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;First Search&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myapp Operation=Creation user_object="user*@mydomain.com"
| dedup RID
| eval dest_user=split(user_object,"@")
| eval extracteduser=mvindex(dest_user,0)
| join type=inner extracteduser
[search index=ad EventCode=4728
| rex field=user "^(?extracteduser&amp;gt;[^\,]+)"
| eval extracteduser=split(extracteduser,"=")
| eval extracteduser=mvindex(extracteduser,1) | fields Group_Name, extracteduser]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my example I will get 3 returned results.&amp;nbsp; USERA which was added to the application AND was added as a member to the AD group; USERB which was added to the application AND was added as a member to the AD group; and USERC which was added to the application but NOT added as a member to the AD group (myapp_users).&amp;nbsp; The problem becomes that in the results that are returned I see&lt;/P&gt;&lt;P&gt;For the event returned for USERA and USERC, I see&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Operation=Create
user_object=USERA
extracteduser=USERA

Operation=Create
user_object=USERB
extracteduser=USERA&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however for the USERC event, I see&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Operation=Create
user_object=USERC
extracteduser=USERA&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so I am getting the wrong extracteduser for the USERC event (no doubt because of the join).&amp;nbsp; I have then abandoned the join and moved to a multi-search&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Second Search&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| multisearch
[search index=myapp Operation=Creation user_object="user*@mydomain.com" | rename user_object as app_newuser]
[search index=ad EventCode=4728" Group_Name="myapp_users" | rename user AS adperm_user]
| rex field=adperm_user "^(?&amp;lt;extracteduser&amp;gt;[^\,]+)"
| rex field=extracteduser "(?&amp;lt;CNAttrib&amp;gt;CN=(?&amp;lt;ad_user&amp;gt;.+))"
| eval app_newuser=split(app_newuser,"@")
| eval app_newuser=mvindex(app_newuser,0)
| eval app_newuser=lower(app_newuser)
| eval ad_user=lower(ad_user)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me 2 fields that I now need to compare&lt;/P&gt;&lt;P&gt;ad_user shows USERA and USERB &amp;lt;-- these users were added to the AD group AND the app&lt;BR /&gt;app_newuser shows USERA, USERB, and USERC &amp;lt;-- these 3 users were added to the app&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result that I want in the end is to only show USERC as that was not a member of the AD group.&amp;nbsp; I have tried using something like the following but come up blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where NOT app_newuser = ad_user

| search NOT app_newuser = ad_user&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have probably made this more complicated than it needs to be, but am stuck now.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 07:20:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-2-results-and-showing-difference/m-p/540478#M152913</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2021-02-19T07:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing 2 results and showing difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-2-results-and-showing-difference/m-p/540487#M152914</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=myapp AND Operation=Creation AND user_object="user*@mydomain.com") OR (index=ad AND EventCode=4728" AND Group_Name="myapp_users")
| rename user_object as app_newuser
| rename user AS adperm_user
| rex field=adperm_user "^(?&amp;lt;extracteduser&amp;gt;[^\,]+)"
| rex field=extracteduser "(?&amp;lt;CNAttrib&amp;gt;CN=(?&amp;lt;user&amp;gt;.+))"
| eval app_newuser=split(app_newuser,"@")
| eval user=mvindex(app_newuser,0)
| eval user=lower(user)
| stats values(*) as * by user
| fillnull value="NA" Group_Name
| where Group_Name="NA"&lt;/LI-CODE&gt;&lt;P&gt;Essentially, extract the user from whichever field it appears in, then "join" with stats, finally determine which users don't have an entry in AD&lt;/P&gt;&lt;P&gt;You may need to play around with field names depending on your actually data e.g. you might want to remove fields you are not interested in before the stats values(*)&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 08:06:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-2-results-and-showing-difference/m-p/540487#M152914</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-19T08:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing 2 results and showing difference</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-2-results-and-showing-difference/m-p/540496#M152916</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; I neglected to use "index OR index" as an an option.&amp;nbsp; I will definitely remove fields as the real data has a lot more data in it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 08:42:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-2-results-and-showing-difference/m-p/540496#M152916</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2021-02-19T08:42:56Z</dc:date>
    </item>
  </channel>
</rss>

