<?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: Finding users currently logged in to my app in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311751#M93414</link>
    <description>&lt;P&gt;@elliotproebstel - Acceptable, and gets the right result.  However, overriding the builtin &lt;CODE&gt;_time&lt;/CODE&gt; field with different data should be avoided, in my opinion, other than for presentation such as in &lt;CODE&gt;timechart&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Also, note @richgalloway's answer as slightly more elegant, since &lt;CODE&gt;dedup&lt;/CODE&gt; will automatically select the first event, which in the default order will be the most recent. &lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2017 03:05:34 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-10-23T03:05:34Z</dc:date>
    <item>
      <title>Finding users currently logged in to my app</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311748#M93411</link>
      <description>&lt;P&gt;For some reason I am having a real hard time wrapping my head around something.....  We have an application where we need to track who is currently logged in.  The application writes a log entry when they login and when they logoff.  They can login concurrently from multiple stations as well.&lt;/P&gt;

&lt;P&gt;So what I need to figure out is if time of login for that user/station combo is higher than the logout time for that user/station combo then we assume they are still logged.  So the outcome will need to be a table that shows the ID, Station and time of the current logged in users.&lt;/P&gt;

&lt;P&gt;Here is a sample of the data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ACTION                  STATION                UID                   au_Time
Login                  1.2                                 123456            2017-10-19 09:15:45.0
Login                  1.3                                 987654            2017-10-19 09:24:35.0
Login                  1.4                                 ABCDEF            2017-10-19 09:40:27.0
Login                  1.3                                 XYZPDQ            2017-10-19 10:10:34.0
Login                  1.6                                 XYZPDQ            2017-10-19 10:11:48.0
Login                  1.5                                 XXX111            2017-10-19 09:40:38.0
Logoff                 1.3                                 987654            2017-10-19 09:44:40.0
Logoff                 1.2                                 123456            2017-10-18 14:57:12.0
Logoff                 1.6                                 XYZPDQ            2017-10-19 10:38:52.0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the example above you see UID 987654 logged in at 9:24 and logged out at 9:44 so they are not currently logged in&lt;BR /&gt;
- User 123456 last logout was on the 18th at 14:57 and they logged in again on the 19th at 9:15.  So they are currently logged in&lt;BR /&gt;
- User XYZPDQ logged in to station 1.6 at 10:11 on the 19th and logged of of station 1.6 at 1:38 but this user XYZPDQ is still looed in on station 1.3&lt;/P&gt;

&lt;P&gt;I just cant figure out the best way to see if that user and station has a greater time for logout than they do for login to decide if they are currently logged in or not.&lt;/P&gt;

&lt;P&gt;Thanks for any help !!! &lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 15:42:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311748#M93411</guid>
      <dc:creator>cjmckenna</dc:creator>
      <dc:date>2017-10-19T15:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Finding users currently logged in to my app</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311749#M93412</link>
      <description>&lt;P&gt;First, convert the timestamps from strings to epoch time:&lt;BR /&gt;
&lt;CODE&gt;| eval _time=strptime(au_Time, "%F %X.%1Q")&lt;/CODE&gt;&lt;BR /&gt;
Then add a field called latest_time to each event. This field will contain the timestamp of the latest event for that given station:&lt;BR /&gt;
&lt;CODE&gt;| eventstats latest(_time) AS latest_time BY STATION&lt;/CODE&gt;&lt;BR /&gt;
Then search for only events where the timestamp of the entry is the same as the latest timestamp:&lt;BR /&gt;
&lt;CODE&gt;| where latest_time=_time&lt;/CODE&gt;&lt;BR /&gt;
This will give you only the lines containing the latest event for each station. From there, you can manipulate the data to output exactly what you need.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:17:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311749#M93412</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2020-09-29T16:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Finding users currently logged in to my app</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311750#M93413</link>
      <description>&lt;P&gt;You can do that by filtering out all but the most recent event for each station/user pair.  That will leave either a Login or a Logout for each.  Then display just the Logins and you'll have your list of those you are still logged in.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | dedup STATION UID | where ACTION=Login | table ACTION STATION UID _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Oct 2017 19:13:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311750#M93413</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-10-19T19:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Finding users currently logged in to my app</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311751#M93414</link>
      <description>&lt;P&gt;@elliotproebstel - Acceptable, and gets the right result.  However, overriding the builtin &lt;CODE&gt;_time&lt;/CODE&gt; field with different data should be avoided, in my opinion, other than for presentation such as in &lt;CODE&gt;timechart&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Also, note @richgalloway's answer as slightly more elegant, since &lt;CODE&gt;dedup&lt;/CODE&gt; will automatically select the first event, which in the default order will be the most recent. &lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 03:05:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311751#M93414</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-23T03:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding users currently logged in to my app</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311752#M93415</link>
      <description>&lt;P&gt;@richgalloway - Put quotes around &lt;CODE&gt;"Login"&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 03:06:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-users-currently-logged-in-to-my-app/m-p/311752#M93415</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-23T03:06:11Z</dc:date>
    </item>
  </channel>
</rss>

