Rust Server Metrics
Carbon Rust Server Metrics (RSM) is a Harmony-based module that collects metrics from Rust game servers running Carbon forked from Rust.ServerMetrics.
Source: CarbonCommunity/Carbon.RSM
Setup
- Install Grafana 9 or newer and InfluxDB 1.8 on a server. InfluxDB 2.0 and newer are not compatible.
- Set both
max-values-per-tagandmax-series-per-databaseto0in the InfluxDB configuration. This is required for the volume of data stored by player metrics. - Restart InfluxDB to apply the changes.
- Create an InfluxDB database with an appropriate retention policy. A suggested starting point is 12 weeks of retention with a 24-hour shard group duration.
- Create a user with write permissions on that database.
- Import the dashboard into Grafana and configure the DataSource variable.
- Stop the Rust server.
- Download the latest
Carbon.Windows.RSM.dllorCarbon.Linux.RSM.dllfrom the RSM release page and copy it tocarbon/managed/modulesin the server directory. - Start the Rust server.
- Once the server has started and the module has loaded, edit
HarmonyMods_Data/ServerMetrics/Configuration.jsonusing the configuration details below. - Run
servermetrics.reloadcfgto reload the configuration.
InfluxDB limits
Leaving the default max-values-per-tag and max-series-per-database limits in place will eventually cause metric submissions to fail and data to be lost.
DLL changes
Never update or delete a Harmony mod DLL while the Rust server is running. Doing so can cause invalid IL exceptions and eventually crash the server.
Configuration
Example
{
"Enabled": true,
"Influx Database Url": "https://my-influx-database:8086",
"Influx Database Name": "rust-server-metrics",
"Influx Database User": "my-database-user",
"Influx Database Password": "my-super-secret-password-thats-a-decent-size",
"Server Tag": "us-10x",
"Debug Logging": false,
"Amount of metrics to submit in each request": 1000
}Settings
| Setting | Description |
|---|---|
Enabled | When true, collects metrics and submits them to the configured InfluxDB database. |
Influx Database Url | The URL used to access InfluxDB. A valid SSL certificate is strongly recommended when accessing the database over the internet. |
Influx Database Name | The name of the database created during setup. |
Influx Database User | The username of the database user created during setup. |
Influx Database Password | The password for that database user. |
Server Tag | A static tag added to every record submitted by the server. Use a different tag for each Rust server. |
Debug Logging | Logs the raw HTTP response for failed submissions. Disable this after the server is connected, as it can cause performance issues. |
Amount of metrics to submit in each request | The number of statistics records sent in each HTTP request. The minimum value is 1000. |
Multiple servers
Multiple Rust servers can submit data to the same InfluxDB database when each uses a different Server Tag.
Submission Batch Size
Setting Amount of metrics to submit in each request too high can increase submission times and affect server FPS. Setting it too low can cause records to be discarded if they are generated faster than they can be sent.
The project reports testing servers with 200–600 players without issues at a batch size of 1000.
Commands
| Command | Description |
|---|---|
servermetrics.reloadcfg | Reloads changes made to the configuration file. |
servermetrics.status | Shows whether the module is ready to collect metrics, whether the uploader is sending an HTTP request, and how many records are in the send buffer. |
Report Buffer
The report buffer has a fixed capacity of 100,000 reports. Once this capacity is exceeded, reports are discarded, resulting in missing data in Grafana.
Monitor the buffer size when changing Amount of metrics to submit in each request.
Securing InfluxDB 1.8
Database access
An unsecured InfluxDB instance can expose data to the public. Complete the security steps below.
Enable Authentication
Open
influxdb.conf, usually located in/etc/influxdb/.Set
auth-enabledtotruein the[http]section:toml[http] auth-enabled = trueRestart InfluxDB to apply the change:
bashsudo systemctl restart influxdbOpen the InfluxDB shell:
bashinfluxCreate an administrator account, replacing
<username>and<password>with the required credentials:sqlCREATE USER <username> WITH PASSWORD '<password>' WITH ALL PRIVILEGESOptionally, create additional users with fewer privileges as needed.
Enable HTTPS
Obtain SSL certificates using a service such as Let's Encrypt, or generate a self-signed certificate.
Enable HTTPS in the
[http]section ofinfluxdb.confand provide the certificate and private-key paths:toml[http] https-enabled = true https-certificate = "/path/to/your/certificate.pem" https-private-key = "/path/to/your/privatekey.pem"Restart InfluxDB to apply the changes:
bashsudo systemctl restart influxdb
Firewall Configuration
Configure the firewall to allow only trusted traffic to the InfluxDB ports.
Updates
Regularly check for and apply InfluxDB security patches.
Backups
Back up the database regularly to prevent data loss in the event of a security breach or failure.
