<?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 compare two user lists and find number of distinct users who have successful/failed login events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474613#M133463</link>
    <description>&lt;P&gt;Hi @arjunpkishore5 &lt;/P&gt;

&lt;P&gt;I will test the above and get back to you.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
Adam&lt;/P&gt;</description>
    <pubDate>Sat, 02 Nov 2019 08:51:43 GMT</pubDate>
    <dc:creator>adam_ali_syd</dc:creator>
    <dc:date>2019-11-02T08:51:43Z</dc:date>
    <item>
      <title>How to compare two user lists and find number of distinct users who have successful/failed login events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474611#M133461</link>
      <description>&lt;P&gt;I need some help in formulating a complex search command. The requirement is to take one list (list2) of users and see which ones on the list don't match the ones on the other list (list1).&lt;/P&gt;

&lt;P&gt;I have a set of events for users logins as per the below:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;_time                                          username                       loginStatus&lt;/STRONG&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;STRONG&gt;2019-10-30 19:00:39.819      &lt;A href="mailto:theCrazy1@gmail.com"&gt;theCrazy1@gmail.com&lt;/A&gt;      success&lt;BR /&gt;
2019-10-30 19:00:28.266      &lt;A href="mailto:theCrazy1@gmail.com"&gt;theCrazy1@gmail.com&lt;/A&gt;      fail&lt;BR /&gt;
2019-10-30 19:00:13.158      &lt;A href="mailto:theCrazy2@gmail.com"&gt;theCrazy2@gmail.com&lt;/A&gt;      success&lt;BR /&gt;
2019-10-30 19:00:12.383      &lt;A href="mailto:theCrazy2@gmail.com"&gt;theCrazy2@gmail.com&lt;/A&gt;      fail&lt;BR /&gt;
2019-10-30 19:00:12.381      &lt;A href="mailto:theCrazy3@gmail.com"&gt;theCrazy3@gmail.com&lt;/A&gt;      fail&lt;BR /&gt;
2019-10-30 19:00:12.382      &lt;A href="mailto:theCrazy4@gmail.com"&gt;theCrazy4@gmail.com&lt;/A&gt;      fail&lt;BR /&gt;
2019-10-30 19:00:12.384      &lt;A href="mailto:theCrazy5@gmail.com"&gt;theCrazy5@gmail.com&lt;/A&gt;      fail&lt;BR /&gt;
2019-10-30 19:00:12.385      &lt;A href="mailto:theCrazy6@gmail.com"&gt;theCrazy6@gmail.com&lt;/A&gt;      fail&lt;BR /&gt;
2019-10-30 19:00:12.386      &lt;A href="mailto:theCrazy7@gmail.com"&gt;theCrazy7@gmail.com&lt;/A&gt;      fail&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;As you can see from the above, some users have an event for successful logins as well as an event for failed logins. Some other users have only failed login events. I want to a search command that can return the below:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;number of distinct users who have successful login events

&lt;UL&gt;
&lt;LI&gt;|tstats dc(username) where loginStatus::success by loginStatus&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;number of distinct users who has failed login events but no successful login events

&lt;UL&gt;
&lt;LI&gt;no idea how to do that based on 1 above&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Based on the above, the result should be:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Success   failed&lt;/STRONG&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;STRONG&gt;2               5&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Could you please confirm the below:&lt;BR /&gt;
 - Can Splunk do that?&lt;BR /&gt;
 - If yes, what would be the most efficient way to do it?&lt;BR /&gt;
 - Can you give the exact search command based on the above?&lt;/P&gt;

&lt;P&gt;The only thing I could come up with was the below which didn't work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex  loginStatus::success | table username |rename username AS username2 |dedup username2 sortBy username2 | append [search index= myindex  loginStatus::fail | table username | dedup username sortBy username] | diff diff maxlen=0 attribute= username
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Nov 2019 21:43:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474611#M133461</guid>
      <dc:creator>adam_ali_syd</dc:creator>
      <dc:date>2019-11-01T21:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two user lists and find number of distinct users who have successful/failed login events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474612#M133462</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
| stats count(eval(loginStatus=="success")) as success,count(eval(loginStatus=="fail")) as fail by username
| fillnull success value=0
| stats dc(eval(if(success&amp;gt;0, username,null()))) as success, dc(eval(if(success==0, username,null()))) as fail
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2019 23:16:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474612#M133462</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2019-11-01T23:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two user lists and find number of distinct users who have successful/failed login events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474613#M133463</link>
      <description>&lt;P&gt;Hi @arjunpkishore5 &lt;/P&gt;

&lt;P&gt;I will test the above and get back to you.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
Adam&lt;/P&gt;</description>
      <pubDate>Sat, 02 Nov 2019 08:51:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474613#M133463</guid>
      <dc:creator>adam_ali_syd</dc:creator>
      <dc:date>2019-11-02T08:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two user lists and find number of distinct users who have successful/failed login events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474614#M133464</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval _raw="
                   time            username loginStatus
2019-10-30T19:00:39.819 theCrazy1@gmail.com success
2019-10-30T19:00:28.266 theCrazy1@gmail.com fail
2019-10-30T19:00:13.158 theCrazy2@gmail.com success
2019-10-30T19:00:12.383 theCrazy2@gmail.com fail
2019-10-30T19:00:12.381 theCrazy3@gmail.com fail
2019-10-30T19:00:12.382 theCrazy4@gmail.com fail
2019-10-30T19:00:12.384 theCrazy5@gmail.com fail
2019-10-30T19:00:12.385 theCrazy6@gmail.com fail
2019-10-30T19:00:12.386 theCrazy7@gmail.com fail"
| multikv forceheader=1 copyattrs=f
| eval _time = strptime(time, "%Y-%m-%dT%H:%M:%S.%3N")
| table _time username loginStatus
| sort 0 - _time

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| dedup username
| stats count BY loginStatus
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Nov 2019 00:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-user-lists-and-find-number-of-distinct-users/m-p/474614#M133464</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-10T00:18:14Z</dc:date>
    </item>
  </channel>
</rss>

