Chapter 6 Metrics captures and provides a variety of metrics to help you gain insight into the use of your applications and your account in general. The metrics include active hours by application, number of connections, CPU, memory and network usage, and the number of worker processes.

6.1 Account metrics

Account metrics are viewable within the dashboard under Account -> Usage. The default view is the number of hours used in the current subscription cycle, with a breakdown of the applications used and their contribution to the active hours. You can change the date ranges by using the drop down to select: 1 Day, 1 Week, 1 Month, or 3 month views.

6.2 Application metrics

Each application’s metrics are available under the Metrics tab within the application’s view on the dashboard.

Many of the metrics described here are available for download as a dataframe through the use of the rsconnect::showMetrics API.

## Example of loading user CPU metrics
df <- rsconnect::showMetrics("container.cpu",c("cpu.user"), server="")
Table 6.1: Available series and metrics
Series Metric Description
container.cpu cpu.user CPU usage in user space
container.cpu cpu.system CPU usage in system time network.tx Network traffic transmitted from the application instances network.rx Network traffic received by the application instances
container.memory total_rss The amount of memory that does not correspond to anything on disk: stacks, heaps, and anonymous memory maps
container.memory total_cache The amount of memory used that can be associated precisely with a block on a block device

6.3 Tracking user and session information

Every new browser that accesses an application will create a user session. The client data and user information (if it is an authenticated user) are accessible within your shiny application and can be logged to third party data stores (databases, log aggregation services, or web analytics platforms) as your needs require.

For authenticated applications, user name information is accessible through the session$user variable and can be used to customize your application’s behavior. If you are interested in customizing your application based on the identity of the user, please refer to the user permissions article on the shiny developer center

6.3.1 Google Analytics

Shiny applications use standard HTML, CSS and JavaScript technologies on the front end so you can track your application’s usage using your favorite web analytics platform. Most of these platforms will require the insertion of a piece of JavaScript on the pages that are rendered.

For an example of integrating a shiny application with Google Analytics, please see the using Google Analytics with shiny article. The techniques described there will be very similar for other web analytics tools.