<?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 distinctively count concurrent users when event has userid, logindate, logoutdate in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492645#M1638</link>
    <description>&lt;P&gt;This absolutely is a use-case for the &lt;CODE&gt;concurrency&lt;/CODE&gt; command; see my answer here for everything that you need:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/319585/how-to-graph-the-number-of-active-sessions-over-ti.html"&gt;https://answers.splunk.com/answers/319585/how-to-graph-the-number-of-active-sessions-over-ti.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Mar 2020 16:22:12 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2020-03-17T16:22:12Z</dc:date>
    <item>
      <title>How to distinctively count concurrent users when event has userid, logindate, logoutdate</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492643#M1636</link>
      <description>&lt;P&gt;Hi everyone, I have the following event format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                   logindate               logoutdate              userid
2019-07-25 09:41:21     25/07/2019 09:41:21     25/07/2019 13:47:52     USER1
2019-07-25 09:41:02     25/07/2019 09:41:02     25/07/2019 11:43:17     USER2
2019-07-25 09:39:56     25/07/2019 09:39:56     25/07/2019 13:01:17     USER4
2019-07-25 09:39:45     25/07/2019 09:39:45     25/07/2019 11:39:58     USER3
2019-07-25 09:39:15     25/07/2019 09:39:15     25/07/2019 10:32:34     USER2
2019-07-25 09:38:04     25/07/2019 09:38:04     25/07/2019 11:39:07     USER1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;logindate and _time have the same value, because splunk considered the logindate field as the event _time automatically.&lt;/P&gt;

&lt;P&gt;What I need to accomplish is to count distinctively the number of users that were logged in at the same time. I have studied the concurrency command, but I don't think it solves my problem since I need to count distinct users.&lt;/P&gt;

&lt;P&gt;I was able to solve this in SQL (where these values are acctualy stored) by creating an auxliary table with just timestamps ranging from the earliest logindate to the latest logout date, incremented by the hour and then inner joining that table to data table whenever the timestamp from the dummy table was between logindate and logoutdate.&lt;/P&gt;

&lt;P&gt;Could I accomplish something similar or better in Splunk?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 14:54:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492643#M1636</guid>
      <dc:creator>rodrigorenie</dc:creator>
      <dc:date>2020-03-17T14:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to distinctively count concurrent users when event has userid, logindate, logoutdate</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492644#M1637</link>
      <description>&lt;P&gt;Have you looked at streamstats?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 15:55:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492644#M1637</guid>
      <dc:creator>rmmiller</dc:creator>
      <dc:date>2020-03-17T15:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to distinctively count concurrent users when event has userid, logindate, logoutdate</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492645#M1638</link>
      <description>&lt;P&gt;This absolutely is a use-case for the &lt;CODE&gt;concurrency&lt;/CODE&gt; command; see my answer here for everything that you need:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/319585/how-to-graph-the-number-of-active-sessions-over-ti.html"&gt;https://answers.splunk.com/answers/319585/how-to-graph-the-number-of-active-sessions-over-ti.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 16:22:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492645#M1638</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-17T16:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to distinctively count concurrent users when event has userid, logindate, logoutdate</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492646#M1639</link>
      <description>&lt;P&gt;I was looking at the answer you posted, and noticed a main difference: a already have the &lt;CODE&gt;logindate&lt;/CODE&gt; and &lt;CODE&gt;logoutdate&lt;/CODE&gt; fields in every event, so could I replace everything from the beginning up until before the &lt;CODE&gt;table&lt;/CODE&gt; command with just &lt;CODE&gt;eval duration = logoutdate - logindate&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;Also, how does appending the &lt;CODE&gt;gentimes&lt;/CODE&gt; result to the &lt;CODE&gt;table logindate, duration&lt;/CODE&gt; garantees that I will be able to count distinct users?&lt;/P&gt;

&lt;P&gt;This log is from an Application which is licensed by Concurrent Users and the same user logged in several times during the same period &lt;STRONG&gt;does not count&lt;/STRONG&gt; as multiple concurrent user.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 17:55:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492646#M1639</guid>
      <dc:creator>rodrigorenie</dc:creator>
      <dc:date>2020-03-17T17:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to distinctively count concurrent users when event has userid, logindate, logoutdate</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492647#M1640</link>
      <description>&lt;P&gt;Yes, you are correct about &lt;CODE&gt;duration&lt;/CODE&gt;.  The &lt;CODE&gt;gentimes&lt;/CODE&gt; sets the timeframe inside of which to count &lt;CODE&gt;concurency&lt;/CODE&gt; (e.g. hourly concurrent users).  However you are correct; there is nothing that would allow you to count &lt;CODE&gt;distinctly&lt;/CODE&gt; so this is not a complete answer.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 02:36:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492647#M1640</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-18T02:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to distinctively count concurrent users when event has userid, logindate, logoutdate</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492648#M1641</link>
      <description>&lt;P&gt;I was able to solve this by creating a range of dates between &lt;CODE&gt;logindate&lt;/CODE&gt; and &lt;CODE&gt;logoutdate&lt;/CODE&gt; and turning that field into the new &lt;CODE&gt;_time&lt;/CODE&gt; field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch
| eval logindate = strptime(logindate, "%d/%m/%Y %H:%M:%S") | bin span=1m logindate
| eval logoutdate = strptime(logoutdate, "%d/%m/%Y %H:%M:%S") | bin span=1m logoutdate
| eval range = mvrange(logindate, logoutdate, "1m") 
| field - _time 
| rename range as _time
| timechart span=5m limit=10 otherstr=Outros distinct_count(userid)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;First I had to convert the fields &lt;CODE&gt;logindate&lt;/CODE&gt; and &lt;CODE&gt;logoutdate&lt;/CODE&gt; to proper datetime, and then I used the &lt;CODE&gt;bin&lt;/CODE&gt; command just to snap &lt;CODE&gt;logindate&lt;/CODE&gt; and &lt;CODE&gt;logoutdate&lt;/CODE&gt; back to their earliest minute, but that's optional.&lt;/P&gt;

&lt;P&gt;I used &lt;CODE&gt;mvrange&lt;/CODE&gt; to create a multivalued field of dates wich range between &lt;CODE&gt;logindate&lt;/CODE&gt; and &lt;CODE&gt;logoutdate&lt;/CODE&gt; every 1 minute. Then I got rid of the original &lt;CODE&gt;_time&lt;/CODE&gt; field and replaced it with the &lt;CODE&gt;range&lt;/CODE&gt; field.&lt;/P&gt;

&lt;P&gt;After that, a simple &lt;CODE&gt;timechart&lt;/CODE&gt; will do the trick.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 14:51:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-distinctively-count-concurrent-users-when-event-has/m-p/492648#M1641</guid>
      <dc:creator>rodrigorenie</dc:creator>
      <dc:date>2020-03-20T14:51:15Z</dc:date>
    </item>
  </channel>
</rss>

