Forum Discussion

phoneboy's avatar
phoneboy
Director
2 years ago

Online User Count is Completely Wrong

I'm trying to get an accurate count of online users and it's quite obvious the count is completely wrong just by looking at the results I'm encountering on my staging environment.
The LIQL query used is fairly simple:

SELECT count(*) FROM users WHERE online_status='online'

Given the number of people who access our staging server, I would expect the result of this to be a low single digit number.
Instead, I got a result of over 30 users.
So I dug into the API results:

SELECT login,last_visit_time FROM users WHERE online_status='online'

The results list users with last visit times from 2020 and 2021 as well as users from earlier in 2022 that I know for a fact aren't online.

How is Khoros defining an "online user" here?
Is the behavior I'm seeing a bug or expected behavior?

    • BlakeH's avatar
      BlakeH
      Khoros Staff

      Thanks for this! Will pass on to the docs team.

  • SharathTP's avatar
    SharathTP
    Khoros Alumni (Retired)

    Hi, 
    The liql query

     

     

    SELECT count(*) FROM users WHERE online_status='online'

     

     

     returns the count including the anonymous user sessions as well. 
    The count returned should be matching the total count of members and guests online in the 'users online page'  

     

     

    <community>/t5/forums/usersonlinepage

     

     

    This can be checked to know whether the count returned by the liql is accurate. 

    Coming to the part where the query 

     

     

    SELECT login,last_visit_time FROM users WHERE online_status='online'

     

     

    is returning the users who logged-in in 2021 etc.  We didn't observe this issue in our qa sites. In case you are still seeing any discrepancy, we request you to create a support ticket with the relevant details for further analysis. 

    • phoneboy's avatar
      phoneboy
      Director

      All the /t5/forums/usersonlinepage tells me is what I learned from parsing the API results directly: there are named users marked "online" that I know for a fact are not.

      And yes, I already have a support ticket open on this.

  • Hello, can you please try to use rest call for this:

     

     <#assign online_user_count = rest('/users/online/count').value?number />

     

    • phoneboy's avatar
      phoneboy
      Director

      On my staging environment, I see the following in my component that displays the platform stats.
      I put the v1 and v2 API method in the component I'm using to display stats and got very different results:

      • Online Users v2: 17
      • Online Users v1: 678

      Given there aren't even 678 users defined in my staging environment, how can this even be considered accurate?

  • phoneboy Online User count is definitely a metric our team has been struggling with as well!

    Khoros case tech advised to use Community APIv1 and not APIv2, and not to include duplicate values, but we're still seeing incorrect online users .

     

    • phoneboy's avatar
      phoneboy
      Director

      I tried v1 and got similarly wrong results.
      Either way, the results are clearly wrong and/or include a definition of "online" that we're not aware of.