<?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 to get the Weekly Stats based on the Username in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-Weekly-Stats-based-on-the-Username/m-p/448953#M127180</link>
    <description>&lt;P&gt;Hi, I am looking for some help related to one of the issues. So what i want is weekly view of users in last 90 days with their authentication status. For example in a particular week if a user has "failed login" and "success login" both and suppose in the next week, he just got success, then I want it to be reported in a table like this - &lt;/P&gt;

&lt;P&gt;FirstDayOfTheWeek            User                              AuthenticationStatus&lt;BR /&gt;
01-04-2019                      &lt;A href="mailto:test1@gmail.com" target="_blank"&gt;test1@gmail.com&lt;/A&gt;             Failed Success&lt;BR /&gt;
08-04-2019                      &lt;A href="mailto:test1@gmail.com" target="_blank"&gt;test1@gmail.com&lt;/A&gt;             Success&lt;BR /&gt;
08-04-2019                      &lt;A href="mailto:test2@gmail.com" target="_blank"&gt;test2@gmail.com&lt;/A&gt;             Failed&lt;BR /&gt;
15-04-2019                      &lt;A href="mailto:test1@gmail.com" target="_blank"&gt;test1@gmail.com&lt;/A&gt;             Failed Success&lt;/P&gt;

&lt;P&gt;There could be n number of users and I want to report all of them. Is there any way to do this?I am finding it a bit tricky. This is my query where I have appended success logins events with failed login events.&lt;/P&gt;

&lt;P&gt;index="test" sourcetype=test_events "loginSuccess" &lt;BR /&gt;
| dedup currentUsername &lt;BR /&gt;
| eval type="Success" &lt;BR /&gt;
| fields currentUsername type &lt;BR /&gt;
| append &lt;BR /&gt;
    [ search index="test" sourcetype=test_events "loginFailed" 404 &lt;BR /&gt;
    | rename username as currentUsername &lt;BR /&gt;
    | dedup currentUsername &lt;BR /&gt;
    | eval type="Fail" &lt;BR /&gt;
    | fields currentUsername type&lt;BR /&gt;
        ]&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:26:56 GMT</pubDate>
    <dc:creator>Shashank_87</dc:creator>
    <dc:date>2020-09-30T00:26:56Z</dc:date>
    <item>
      <title>How to get the Weekly Stats based on the Username</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-Weekly-Stats-based-on-the-Username/m-p/448953#M127180</link>
      <description>&lt;P&gt;Hi, I am looking for some help related to one of the issues. So what i want is weekly view of users in last 90 days with their authentication status. For example in a particular week if a user has "failed login" and "success login" both and suppose in the next week, he just got success, then I want it to be reported in a table like this - &lt;/P&gt;

&lt;P&gt;FirstDayOfTheWeek            User                              AuthenticationStatus&lt;BR /&gt;
01-04-2019                      &lt;A href="mailto:test1@gmail.com" target="_blank"&gt;test1@gmail.com&lt;/A&gt;             Failed Success&lt;BR /&gt;
08-04-2019                      &lt;A href="mailto:test1@gmail.com" target="_blank"&gt;test1@gmail.com&lt;/A&gt;             Success&lt;BR /&gt;
08-04-2019                      &lt;A href="mailto:test2@gmail.com" target="_blank"&gt;test2@gmail.com&lt;/A&gt;             Failed&lt;BR /&gt;
15-04-2019                      &lt;A href="mailto:test1@gmail.com" target="_blank"&gt;test1@gmail.com&lt;/A&gt;             Failed Success&lt;/P&gt;

&lt;P&gt;There could be n number of users and I want to report all of them. Is there any way to do this?I am finding it a bit tricky. This is my query where I have appended success logins events with failed login events.&lt;/P&gt;

&lt;P&gt;index="test" sourcetype=test_events "loginSuccess" &lt;BR /&gt;
| dedup currentUsername &lt;BR /&gt;
| eval type="Success" &lt;BR /&gt;
| fields currentUsername type &lt;BR /&gt;
| append &lt;BR /&gt;
    [ search index="test" sourcetype=test_events "loginFailed" 404 &lt;BR /&gt;
    | rename username as currentUsername &lt;BR /&gt;
    | dedup currentUsername &lt;BR /&gt;
    | eval type="Fail" &lt;BR /&gt;
    | fields currentUsername type&lt;BR /&gt;
        ]&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:26:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-Weekly-Stats-based-on-the-Username/m-p/448953#M127180</guid>
      <dc:creator>Shashank_87</dc:creator>
      <dc:date>2020-09-30T00:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the Weekly Stats based on the Username</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-Weekly-Stats-based-on-the-Username/m-p/448954#M127181</link>
      <description>&lt;P&gt;I'd suggest using a stats to accomplish this instead of an append:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test" sourcetype=test_events "loginSuccess" OR ("loginFailed" 404)
| eval AuthenticationStatus=if(match(_raw, "loginSuccess"), "Success", "Failed")
| eval FirstDayOfTheWeek=relative_time(_time, "@w+1d")
| stats values(AuthenticationStatus) as AuthenticationStatus by FirstDayOfTheWeek currentUsername 
| rename currentUsername as User
| fieldformat FirstDayOfTheWeek=strftime(FirstDayOfTheWeek, "%d-%m-%Y")
| sort 0 + FirstDayOfTheWeek User
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The OR statement on the first line will have you search both of the conditions you want and then the values command on the stats transformation on line 4 will report the different Authentication statuses as a multivalued field.  Give that a try and let me know if it works for you.&lt;/P&gt;

&lt;P&gt;edited it to account for the currentUsername field instead of User&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 14:08:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-Weekly-Stats-based-on-the-Username/m-p/448954#M127181</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2019-05-08T14:08:46Z</dc:date>
    </item>
  </channel>
</rss>

