<?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 get the difference between 2 queries? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304089#M91445</link>
    <description>&lt;P&gt;what exactly is the final result you desire?&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 20:03:00 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2018-04-04T20:03:00Z</dc:date>
    <item>
      <title>How to get the difference between 2 queries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304088#M91444</link>
      <description>&lt;P&gt;This is the query that reports when a user last changed their password:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit "action=password change"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the query that reports the users in the system:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest /services/authentication/users splunk_server=local 
| fields title roles realname email
| rename title as userN
| rename realname as name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should a join be needed between these 2 queries? But I know that join won't always have results (eg. outer-join) since not all users will have changed passwords recently&lt;/P&gt;

&lt;P&gt;I need to merge that with a report that finds all the accounts, and whether their admins, and then report on the "difference" in the lists.&lt;/P&gt;

&lt;P&gt;I want to result to give me a report of the accounts/users that haven't reset their password in 3 months (or 1 month for administrators)&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 19:58:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304088#M91444</guid>
      <dc:creator>kiamco</dc:creator>
      <dc:date>2018-04-04T19:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the difference between 2 queries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304089#M91445</link>
      <description>&lt;P&gt;what exactly is the final result you desire?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 20:03:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304089#M91445</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-04T20:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the difference between 2 queries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304090#M91446</link>
      <description>&lt;P&gt;A report of the accounts/users that haven't reset their password in 3 months (or 1 month for administrators)&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 20:05:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304090#M91446</guid>
      <dc:creator>kiamco</dc:creator>
      <dc:date>2018-04-04T20:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the difference between 2 queries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304091#M91447</link>
      <description>&lt;P&gt;Try this, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit action="password change"|table timestamp,user,action,info|eval timestamp=strptime(timestamp,"%m-%d-%Y")|eval check_time=relative_time(now(),"-60d@d")|where timestamp&amp;gt;check_time|convert ctime(*time*)|join user[|rest /services/authentication/users|fields title,roles |rename title as user]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 02:57:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304091#M91447</guid>
      <dc:creator>splunker12er</dc:creator>
      <dc:date>2018-04-05T02:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the difference between 2 queries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304092#M91448</link>
      <description>&lt;P&gt;I think this should give you what you're looking for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit "action=password change" 
| stats latest(_time) AS _time BY user 
| append 
    [| rest /services/authentication/users splunk_server=local 
    | fields title roles realname email 
    | rename title as user 
    | rename realname as name ] 
| stats latest(_time) AS _time values(roles) AS roles values(name) AS name values(email) AS email BY user 
| where isnull(_time) OR (_time&amp;lt;relative_time(now(), "-30d@d") AND like(roles, "admin"))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The part before the append will find the latest time a user changed their password. The subsearch will gather the related user information for the whole user base. After that, a second stats call will find the latest &lt;CODE&gt;_time&lt;/CODE&gt; value for each user (and also list their roles, name, and email). Because the subsearch returns data that does not contain &lt;CODE&gt;_time&lt;/CODE&gt; values, the only users with non-null &lt;CODE&gt;_time&lt;/CODE&gt; fields will be users who have changed their passwords sometime during the search time. So if you make the search time 3 months, users who've changed their passwords in the last 3 months will be removed by the &lt;CODE&gt;| where isnull(_time)&lt;/CODE&gt;, and the second half of this clause looks for users with "admin" in their list of roles and checks to see if their most recent password change time is earlier than 30 days prior to now.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 14:21:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304092#M91448</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-04-05T14:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the difference between 2 queries?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304093#M91449</link>
      <description>&lt;P&gt;I tried this out and you almost had it but I was able to fill in the blanks. Thanks that really helped a lot&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 18:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-difference-between-2-queries/m-p/304093#M91449</guid>
      <dc:creator>kiamco</dc:creator>
      <dc:date>2018-04-05T18:24:12Z</dc:date>
    </item>
  </channel>
</rss>

