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.

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:

require(tidyverse) 
require(lubridate)
require(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

Unlike RStudio Connect, RStudio Server Pro administrators must analyze a log file in order to count the number of named users. If you have a named user license for RStudio Server Pro, it is critical that you enable the session audit log immediately upon installing 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;

Ensure that session auditing is enabled for every RStudio Server Pro instance. When it is time to report named users, first copy the session audit log /var/lib/rstudio-server/audit/r-sessions/r-sessions.csv to a central directory for analysis. Copy the audit logs from each RStudio Server Pro instance.

Within the directory containing the audit logs, use R to identify the unique named users over the last year. Sample R code is below:

require(tidyverse)
require(lubridate)
require(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)}.')

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

 

 

Comments