Interpreting rsconnect::showMetrics connect_count when more than 1 instance is running

I'm interested in using rsconnect::showMetrics to track over time how many concurrent users I have visiting my app, so I have an understanding of peak load.

The connect_count metric is great for this if I have only 1 instance of the app. But if I have more than 1 instance set up, it looks like connect_count is giving me the mean number of connections across however many instances of the app were running at each point in time.

E.g. I've tested deliberately starting all 10 instances of the app (on a Professional plan), and getting 4 of my colleagues to connect to it. showMetrics then gives me a connect_count of 0.4. But if I have 4 instances running and the same 4 colleagues connected, showMetrics gives me a connect_count of 1.

Have I got that right?
And if so, is that the intended behaviour for showMetrics?

It makes showMetrics much less useful, because I can't see a way of also downloading how many instances were running at each point in time.

Any help/advice appreciated!


You are correct that rsconnect::showMetrics returns the mean. Metrics are collected once per minute per application instance. The calculation is the sum of the metric (such as connect_count) over the number of points collected for the interval. This is the default behavior and unfortunately there is currently no parameter to change it.

However if you would like to know how many instances were running each minute for an application I think you should be able to calculate this using the data returned by rsconnect::showUsage. Application usage metrics count the number of instances running each minute and express this as instance hours. So to reverse the calculation and get instances per minute you can multiply each value of the hours column in that dataframe by 60 and round to the nearest integer. Here's an example:

df <- rsconnect::showUsage(account = 'ming', appName = 'myApp', usageType = 'hours', from = '1h', interval = '1m')

    timestamp hours
1  1543592160  0.00
2  1543592220  0.02
3  1543592280  0.03

df$instances <- (round(df$hours * 60))

     timestamp hours instances
1   1543592160  0.00         0
2   1543592220  0.02         1
3   1543592280  0.03         2

I will make a note about investigating improving the metrics API but I suspect that will not make it onto our roadmap for quite a while so I hope this workaround helps in the meantime.



Hi @mingb

That's just what I needed. Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.