Console Auditing in RStudio Workbench / RStudio Server Pro


RStudio Workbench (previously RStudio Server Pro) can be optionally configured to audit all R console activity by writing console input and output to a central location (the /var/lib/rstudio-server/audit/r-console directory by default). This feature can be enabled using the audit-r-console setting. For example:



This will audit all R console input. If you wish to record both console input and output then you can use the all setting. For example:



Note that if you choose to record both input and output you’ll need considerably more storage available than if you record input only. See the Storage Options section below for additional discussion of storage requirements and configuration.

Data Format

The R console activity for each user is written into individual files within the r-console data directory (by default /var/lib/rstudio-server/audit/r-console). The following fields are included:

session_id    Unique identifier for R session where this action occurred.
project    Path to RStudio project directory if the action occurred within a project.
pid    Unix process ID where this console action occurred.
username    Unix user which executed this console action.
timestamp    Timestamp of action in milliseconds since the epoch.
type    Console action type (prompt, input, output, or error).
data    Console data associated with this action (e.g. output text).

The session_id field refers to a concurrent R session as described in the article on Multiple R Sessions (i.e. it can span multiple projects and/or pids).

The default format for the log file is CSV (Comma Separated Values). It’s also possible to write the data to Newline Delimited JSON by using the audit-r-console-format option. For example:


Note that when using the JSON format the entire file is not a valid JSON object but rather each individual line is one. This follows the Newline Delimited JSON specification supported by several libraries including the R jsonlite package.

Storage Options

You can customize both the location where audit data is written as well as the maximum amount of data to log per-user (by default this is 50 MB). To specify the root directory for audit data you use the audit-data-path setting. For example:



To specify the maximum amount of data to write to an individual user’s R console log file you use the audit-r-console-user-limit-mb setting. For example:



The default maximum R console log file size is 50 megabytes per-user. To configure no limit to the size of files which can be written you set the value to 0, for example:



Note that there is no automatic rotation of the audit log files as they get larger. Depending on the number of users and their activity level this means that you should either create a scheduled (e.g. cron) job to periodically move the files off the server onto auxiliary storage and/or ensure that the volume they are stored on has sufficient capacity.

By default console log files are gzip compressed as they are written. You can turn off compression using the audit-r-console-compress option. For example: