Support

Counting Named Users in RStudio Connect and RStudio Server Pro

Follow

You may have an RStudio license that requires you to report an annual number of named users. (Or you may just be curious about how many users are accessing your analytic tools).   Learn how to count named users for RStudio Connect and RStudio Server Pro.  The official definition of a named user is available in the RStudio EULA.

For RStudio Connect, read on. To jump to RStudio Server Pro, click here.

Named Users in RStudio Connect

Administrators can count named users in RStudio Connect by visiting the Connect dashboard or by accessing and analyzing log files.

Counting in the Connect Dashboard

RStudio Connect admins can visit the Admin Dashboard's Metrics page to view a graph of "Active Users" over time. 

For RStudio license reporting, select "1 Year" for the graph duration, and then report the number of active users recorded in the dashboard.

 

active-users.png


The RStudio Connect People dashboard provides RStudio Connect administrators information about users such as the last time they were actively logged in as well as their license status.

 

people-tab.png

 

Analyzing Connect Log Files

Beginning in RStudio Connect 1.7.6, named user sessions can be analyzed using the RStudio Connect audit log. Older versions of RStudio Connect do not track users in the audit log, therefore you can only use this method to count named users if you have been using RStudio Connect 1.7.6 or above for the entire duration of your license

First, create a CSV file with the audit logs for the license period using these commands:

# for Red Hat/CentOS 7, SUSE 12, Ubuntu 16.04, and Ubuntu 18.04
sudo systemctl stop rstudio-connect

# for Red Hat/CentOS 6 and Ubuntu 14.04
sudo stop rstudio-connect

# create a csv with all audit information
# specify the date of the beginning of your license period in YYYY-MM-DD
sudo /opt/rstudio-connect/bin/usermanager audit --csvlog --since 2018-01-01 > audit.csv


If you have multiple distinct RStudio Connect clusters, you can repeat this step for each cluster. You do not need to create an audit.csv file for each node in the same cluster.

Once you have the audit.csv files, you can analyze them in R to get a count of named users. Sample code:

library(tidyverse) 
library(lubridate)
library(glue)

named_users <- map_df(c("audit.csv"), readr::read_csv, col_names = FALSE)
colnames(named_users) <- c("ID", "DateTime","UserID", "User", "Event", "Description")
count <- named_users %>%
filter(Event == "user_login",
DateTime >= today() - dyears(1)) %>%
select("User") %>%
unique() %>%
nrow()

glue('Thanks for using RStudio! This server has had {count} named users since {today() - dyears(1)}.')


If you prefer to have the audit logs continuously available as a CSV or JSON file, set the Server.AuditLogFormat configuration option to either CSV or JSON

Named Users in RStudio Server Pro

Counting in the RStudio Server Admin Dashboard

If you have a single RStudio Server Pro installation, or a cluster that is load balanced, than you can get a view of named users on your RStudio Server Pro instance by accessing the Administrative Dashboard at :

http://<server-address>/admin

If you do not have access to the admin dashboard, you will need to enable the dashboard here. The users tab of the dashboard provides information on user sessions. As of RStudio Server Pro v1.3, at the bottom of this page is information on the number of current named users and total available named users. 

A named user is any person who has logged in to RStudio Server Pro within the last year. However, because named user counting is only available in RStudio Server Pro v1.3+, when you first upgrade to v1.3 your count will begin at 0 even if older user history exists.

mceclip1.png

Counting Named Users Across RStudio Server Pro Installations

If you have more than one distinct RStudio Server Pro installation accessed through different URLs, for example, if you have a European installation and an American installation, than you will need to manually aggregate the number of named users for license reporting.  To do so, we recommend enabling the session audit log immediately in RStudio Server Pro. RStudio Server Pro versions greater than 1.2.1335 may automatically turn on session logs if your license requires them.

To enable session logging, follow these instructions:

    1. Edit /etc/rstudio/rserver.conf to include:    

audit-r-sessions=1

    2. Restart RStudio Server Pro:

sudo rstudio-server stop; sudo rstudio-server start;

Once session auditing is enabled it is easy to count users across all installations. When you are ready to report licensed users, simply copy the session audit log /var/lib/rstudio-server/audit/r-sessions/r-sessions.csv to a central directory from each RStudio Server Pro instance.

Within the directory containing the copied audit logs, you can use R (or any other tool) to identify the unique named users over the last year. For example, in R you could run the following code:

library(tidyverse)
library(lubridate)
library(glue)

named_users <- map_df(list.files(".", "*\\.csv"), readr::read_csv) %>% 
  mutate(time = as_datetime(timestamp/1e3)) %>% 
  filter(time >= today() - dyears(1)) %>% 
  filter(type == "session_start") %>% 
  select(username) %>% 
  unique() %>% 
  nrow()
  
glue('Thanks for using RStudio! This server has had {named_users} named users since {today() - dyears(1)}.')

Note that this script counts all users in the past year based on whether they have started a session. If you have subsequently locked users, just subtract the number of locked users from the total.

 

Please contact support@rstudio.com or sales@rstudio.com if you need assistance calculating the number of named users.

 

 

Comments