Skip to main content

Prometheus metrics

qui exposes Prometheus metrics for its process and qBittorrent instances. The metrics server uses a separate port. The default port is 9074.

If you do not configure basic authentication, the metrics server accepts every request. Bind the server to a private interface, or protect it before you expose it to a network.

Enable metrics

qui disables metrics by default. Enable them in the configuration file or with environment variables.

Configuration file

metricsEnabled = true
metricsHost = "127.0.0.1"
metricsPort = 9074
# metricsBasicAuthUsers = "user:password"

Environment variables

QUI__METRICS_ENABLED=true
QUI__METRICS_HOST=127.0.0.1
QUI__METRICS_PORT=9074
# QUI__METRICS_BASIC_AUTH_USERS="user:password"

qui accepts a comma-separated list of user:password entries. Passwords are plaintext and allow colons. Usernames cannot contain colons. Do not include commas in usernames or passwords.

Protect the configuration file or environment that contains the passwords.

Configure Prometheus

Add qui to your Prometheus scrape configuration:

scrape_configs:
- job_name: qui
static_configs:
- targets: ["localhost:9074"]
metrics_path: /metrics
scrape_interval: 30s
# basic_auth:
# username: prometheus
# password: yourpassword

qui metrics

The qBittorrent metrics use the instance_id and instance_name labels. Tracker metrics also use tracker_name.

MetricTypeLabelsValue and reset behavior
qbittorrent_torrents_downloadingGaugeinstance_id, instance_nameCurrent downloading torrent count.
qbittorrent_torrents_seedingGaugeinstance_id, instance_nameCurrent seeding torrent count.
qbittorrent_torrents_pausedGaugeinstance_id, instance_nameCurrent paused or stopped torrent count.
qbittorrent_torrents_errorGaugeinstance_id, instance_nameCurrent torrent error count.
qbittorrent_torrents_checkingGaugeinstance_id, instance_nameCurrent checking torrent count.
qbittorrent_session_download_bytesCounterinstance_id, instance_nameBytes downloaded during the current qBittorrent session. A qBittorrent restart resets this value.
qbittorrent_session_upload_bytesCounterinstance_id, instance_nameBytes uploaded during the current qBittorrent session. A qBittorrent restart resets this value.
qbittorrent_alltime_download_bytesCounterinstance_id, instance_nameAll-time bytes downloaded by qBittorrent. This value persists across restarts. If you clear qBittorrent's saved statistics, this value resets.
qbittorrent_alltime_upload_bytesCounterinstance_id, instance_nameAll-time bytes uploaded by qBittorrent. This value persists across restarts. If you clear qBittorrent's saved statistics, this value resets.
qbittorrent_instance_connection_statusGaugeinstance_id, instance_name1 for an active, healthy connection. 0 for a disabled or unhealthy instance.
qbittorrent_scrape_errors_totalCounterinstance_id, instance_name, typeA value of 1 for each failed collection sample. A successful collection omits the series.
qbittorrent_tracker_torrentsGaugeinstance_id, instance_name, tracker_nameCurrent torrent count for the tracker group.
qbittorrent_tracker_uploaded_bytesGaugeinstance_id, instance_name, tracker_nameUploaded bytes from current torrents in the tracker group.
qbittorrent_tracker_downloaded_bytesGaugeinstance_id, instance_name, tracker_nameDownloaded bytes from current torrents in the tracker group.
qbittorrent_tracker_total_size_bytesGaugeinstance_id, instance_name, tracker_nameCurrent content size for the tracker group. qui counts a shared content path once within each group.
qui_db_wedged_transaction_totalCounterNoneSQLite nested-transaction detections since qui started. A qui restart resets this value.

qui also exports the standard go_* and process_* metrics from the Prometheus Go client. Those series depend on the Go and client-library versions.

Disabled and disconnected instances expose only qbittorrent_instance_connection_status. qui omits their torrent and transfer metrics.

Tracker metric limits

Tracker metrics describe torrents that remain in qBittorrent. qui does not store tracker history. If you remove a torrent, its transfer totals leave the tracker metrics.

qui assigns a torrent's full transfer totals to each tracker group associated with that torrent. Do not sum tracker groups to calculate unique instance traffic.

If you configure a customization display name, the tracker_name label uses that name. Otherwise, it uses the tracker domain. Included secondary domains contribute to their configured group.

PromQL examples

Tracker totals

Uploaded bytes for current torrents:

sum by (instance_name, tracker_name) (
qbittorrent_tracker_uploaded_bytes
)

Downloaded bytes for current torrents:

sum by (instance_name, tracker_name) (
qbittorrent_tracker_downloaded_bytes
)

Instance transfer rates

The session metrics are counters. rate() handles a qBittorrent restart and returns the average bytes per second.

sum by (instance_name) (
rate(qbittorrent_session_upload_bytes[5m])
)
sum by (instance_name) (
rate(qbittorrent_session_download_bytes[5m])
)

In Grafana, replace [5m] with [$__rate_interval].

Estimated tracker transfer rates

Tracker byte metrics are gauges because their values decrease when torrents leave the library. Use deriv() for an estimate:

sum by (instance_name, tracker_name) (
clamp_min(deriv(qbittorrent_tracker_uploaded_bytes[5m]), 0)
)

A torrent removal hides traffic until that removal leaves the selected time range.

Collection errors

The error collector emits one sample for each failed collection. Count those samples over time:

sum by (instance_name, type) (
sum_over_time(qbittorrent_scrape_errors_total[5m])
)

Do not use rate() or increase() with this metric. It does not retain a cumulative count between scrapes.

Disconnected instances

qbittorrent_instance_connection_status == 0

This query includes disabled instances. Monitor the Prometheus up{job="qui"} metric separately because qui cannot report an unreachable metrics endpoint.

Grafana dashboard

Download the qui Grafana dashboard, then import the JSON file in Grafana. Select the Prometheus data source that scrapes qui.

The dashboard has an instance filter and four panels:

  • qBittorrent connection status
  • session upload and download rates
  • current tracker upload and download totals
  • collection errors during the last five minutes