<?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 find the most recent log event for each user ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-most-recent-log-event-for-each-user/m-p/668641#M229351</link>
    <description>&lt;P&gt;Here is what I am attempting to write SPL to show.&amp;nbsp; I will have users logged into several hosts all using a web application.&amp;nbsp; I want to see the last (most recent) activity performed for each user logged in.&lt;/P&gt;&lt;P&gt;Here is what I have so far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=anIndex sourcetype=aSourcetype&lt;/P&gt;&lt;P&gt;| rex field=_raw "^(?:[^,\n]*,){2}(?P&amp;lt;aLoginID&amp;gt;[^,]+)"&lt;BR /&gt;| rex field=_raw "^\w+\s+\d+_\w+_\w+\s+:\s+\w+\.\w+\.\w+\.\w+\.\w+\.\w+\.\w+\.\w+,(?P&amp;lt;anAction&amp;gt;\w+)"&lt;BR /&gt;| search aLoginID!=null&lt;BR /&gt;| stats max(_time) AS lastAttempt BY host aLoginID&lt;BR /&gt;| eval aTime = strftime(lastAttempt, "%Y-%m-%d %H:%M:%S %p ")&lt;BR /&gt;| sort -aTime&lt;BR /&gt;| table host aLoginID aTime&lt;BR /&gt;| rename host AS "Host", aLoginID AS "User ID", aTime AS "User Last Activity Time"&lt;/P&gt;&lt;P&gt;I am getting my data as expected by host aLoginID but want to only see the most recent anAction ?&lt;/P&gt;&lt;P&gt;When I add in my BY clause host aLoginID anAction I start seeing the userID repeated in my results as I would expect as each anAction "name" is different but I am only seeing one row for each anAction name.&lt;/P&gt;&lt;P&gt;I think I am on the right 'path' but I want to only see 1 row for each user not 1 row for each userID &amp;amp; action ?&lt;/P&gt;</description>
    <pubDate>Tue, 14 Nov 2023 19:32:54 GMT</pubDate>
    <dc:creator>sjringo</dc:creator>
    <dc:date>2023-11-14T19:32:54Z</dc:date>
    <item>
      <title>How to find the most recent log event for each user ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-most-recent-log-event-for-each-user/m-p/668641#M229351</link>
      <description>&lt;P&gt;Here is what I am attempting to write SPL to show.&amp;nbsp; I will have users logged into several hosts all using a web application.&amp;nbsp; I want to see the last (most recent) activity performed for each user logged in.&lt;/P&gt;&lt;P&gt;Here is what I have so far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=anIndex sourcetype=aSourcetype&lt;/P&gt;&lt;P&gt;| rex field=_raw "^(?:[^,\n]*,){2}(?P&amp;lt;aLoginID&amp;gt;[^,]+)"&lt;BR /&gt;| rex field=_raw "^\w+\s+\d+_\w+_\w+\s+:\s+\w+\.\w+\.\w+\.\w+\.\w+\.\w+\.\w+\.\w+,(?P&amp;lt;anAction&amp;gt;\w+)"&lt;BR /&gt;| search aLoginID!=null&lt;BR /&gt;| stats max(_time) AS lastAttempt BY host aLoginID&lt;BR /&gt;| eval aTime = strftime(lastAttempt, "%Y-%m-%d %H:%M:%S %p ")&lt;BR /&gt;| sort -aTime&lt;BR /&gt;| table host aLoginID aTime&lt;BR /&gt;| rename host AS "Host", aLoginID AS "User ID", aTime AS "User Last Activity Time"&lt;/P&gt;&lt;P&gt;I am getting my data as expected by host aLoginID but want to only see the most recent anAction ?&lt;/P&gt;&lt;P&gt;When I add in my BY clause host aLoginID anAction I start seeing the userID repeated in my results as I would expect as each anAction "name" is different but I am only seeing one row for each anAction name.&lt;/P&gt;&lt;P&gt;I think I am on the right 'path' but I want to only see 1 row for each user not 1 row for each userID &amp;amp; action ?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 19:32:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-most-recent-log-event-for-each-user/m-p/668641#M229351</guid>
      <dc:creator>sjringo</dc:creator>
      <dc:date>2023-11-14T19:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the most recent log event for each user ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-most-recent-log-event-for-each-user/m-p/668668#M229359</link>
      <description>&lt;P&gt;Do you want to see the latest action by host AND login id or just the last action by login id?&lt;/P&gt;&lt;P&gt;Anyway, the way to do this is by doing&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats max(_time) AS lastAttempt latest(anAction) as lastAction BY host aLoginID&lt;/LI-CODE&gt;&lt;P&gt;rather than putting action into the split by.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 01:39:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-most-recent-log-event-for-each-user/m-p/668668#M229359</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-11-15T01:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the most recent log event for each user ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-most-recent-log-event-for-each-user/m-p/668672#M229362</link>
      <description>&lt;P&gt;I know I tried latest(...) but like you mentioned I removed anAction from the split and am now seeing only the latest action for each user with no duplicated user ID in the results.&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 02:14:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-most-recent-log-event-for-each-user/m-p/668672#M229362</guid>
      <dc:creator>sjringo</dc:creator>
      <dc:date>2023-11-15T02:14:22Z</dc:date>
    </item>
  </channel>
</rss>

