Counting Named Users in Posit Connect and Posit Workbench / RStudio Server Pro

Follow

You may have a Posit 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 Posit (formerly RStudio) Connect and Posit (formerly RStudio) Workbench.  If you are using legacy RStudio Server Pro, this counting method will also work.  A Named-User license allows a fixed number of named users to have non-sharable user accounts on any single server or across a cluster of servers. The official definition of a named user is available in the Posit EULA

For Posit Connect, read on. To jump to instructions for Posit Workbench, click here.

Named Users in Posit Connect

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

Counting in the Connect Dashboard

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

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

mceclip1.png

 


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

 

mceclip2.png

 

Analyzing Connect Log Files

Named user sessions can be analyzed using the Connect audit log. Older versions of Connect (prior to 1.7.6) do not track users in the audit log, therefore you can only use this method to count named users if you have been using Posit/RStudio Connect 1.7.6 or above for the entire duration of your license. For more about recent Connect logging, see here.

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 Posit 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 Posit! 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

CLI

In addition to manually counting users via the audit log, sol-eng/rstudio-user-counts provides a script that can be run as a command line interface (CLI) to count named users in aggregate or monthly across a specific timeframe.

$ ./named-users-rsc.R -h
usage: named-users-rsc.R [--] [--help] [--monthly] [--debug] [--opts
OPTS] [--min-date MIN-DATE] [--max-date MAX-DATE] [--output
OUTPUT]

Active Posit Connect User Counts. Note that if you are using the
default SQLite database provider, Posit Connect must be stopped to
run this utility. This utility should be executed as root.

flags:
-h, --help show this help message and exit
--monthly Count active users by month
-d, --debug Enable debug output

optional arguments:
-x, --opts RDS file containing argument values
-m, --min-date Minimum date to compute user counts [default:
2020-01-06]
--max-date Maximum date to compute user counts [default:
2021-01-06]
-o, --output Path to write .csv file of user counts [default:
./rsc-user-counts-2021-01-06-16:58:26.csv]

 

Named Users in Posit (formerly RStudio) Workbench

Counting using the Posit Workbench CLI

If you are on Workbench 2021.09 or later, you can use the built-in CLI to list the current users. This CLI will also allow you to easily lock users so they don't count against your named user seat limit. See here for more.

Counting in the Posit Workbench Admin Dashboard

If you have a single Workbench installation, or a cluster that is load balanced, than you can get a view of named users on your server 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. At the bottom of this page is information on the number of current named users and total available named users. (If you are using a license with no user maximum, or an older version of Posit Workbench before RStudio Server Pro v1.3; then, the admin dashboard will not display this license usage).

A named user is any person who has logged in to Posit Workbench within the last year. However, if you recently upgraded from a product version before 1.3, your count will begin at 0 even if older user history exists.

mceclip3.png

Counting Named Users Across Posit Workbench Installations 

If you have more than one distinct Workbench 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 using the Posit Workbench CLI to list all users on each server, then aggregating that in a separate report. See here for more on using the Posit Workbench CLI.

Counting Named Users Across Workbench Installations (on versions older than 2021.09)

If you have more than one distinct Workbench 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 Workbench. Workbench (formerly) RStudio Server Pro versions greater than 1.2.1335 may automatically turn on session logs if you have a named user license.

To enable session logging, follow these instructions:

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

audit-r-sessions=1

    2. Restart Workbench:

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 Workbench 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 Posit! 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.

Counting using a script

In addition to manually counting users via the session log, sol-eng/rstudio-user-counts provides a script that can be run as a command line interface (CLI) to count named users in aggregate or monthly across a specific timeframe.

$ ./named-users-rsp.R -h
usage: named-users-rsp.R [--] [--help] [--monthly] [--debug] [--opts
OPTS] [--log-path LOG-PATH] [--min-date MIN-DATE] [--max-date
MAX-DATE] [--output OUTPUT]

Active Posit Workbench User Counts. This utility should be executed
as root.

flags:
-h, --help show this help message and exit
--monthly Count active users by month
-d, --debug Enable debug output

optional arguments:
-x, --opts RDS file containing argument values
-l, --log-path Path to Session logs [default:
/var/lib/rstudio-server/audit/r-sessions/r-sessions.csv]
-m, --min-date Minimum date to compute user counts [default:
2020-01-06]
--max-date Maximum date to compute user counts [default:
2021-01-06]
-o, --output Path to write .csv file of user counts [default:
./rsp-user-counts-2021-01-06-17:01:23.csv]

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

 

 

Comments