| Crates.io | qbittorrent-metrics-exporter |
| lib.rs | qbittorrent-metrics-exporter |
| version | 0.3.0 |
| created_at | 2025-02-21 23:35:48.108454+00 |
| updated_at | 2025-07-13 17:42:09.124368+00 |
| description | A Prometheus exporter for qBittorrent that provides detailed torrent metrics with support for categories and tags. Collects both per-torrent statistics and aggregated metrics grouped by categories and tags. |
| homepage | |
| repository | https://codeberg.org/anriha/qbittorrent-metrics-exporter |
| max_upload_size | |
| id | 1564883 |
| size | 270,021 |
I created this project to get more detailed metrics from my qBittorrent instances for my Grafana dashboards. It's a Prometheus exporter that collects a wide range of stats and provides powerful aggregation by both category and tag.
It has two backend modes: a simple in-memory one for live data, and a PostgreSQL backend for keeping a permanent history of your torrents.
host, hash, name, and category for easy filtering.The backend determines how metric data is stored. You can choose one based on your needs.
This is the standard, lightweight mode. It fetches the latest stats from qBittorrent and holds them in memory for Prometheus to scrape. Data is refreshed on each scrape and is gone when the exporter restarts. Perfect for live dashboards.
This mode is for keeping long-term statistics. It connects to a PostgreSQL database and saves torrent metrics on every scrape. It will add new torrents and update existing ones, but it never deletes a torrent. This allows you to build a complete history, even for items you've removed from your client.
cargo install qbittorrent-metrics-exporter
First, add the exporter flake to your flake.nix:
# flake.nix
{
inputs = {
# ... your other inputs
# Add this line
qbittorrent-metrics-exporter.url = "github:anriha/qbittorrent-metrics-exporter";
};
outputs = { self, nixpkgs, qbittorrent-metrics-exporter, ... }@inputs: {
nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
# ...
modules = [
# Add this to your list of modules
qbittorrent-metrics-exporter.nixosModules.default
./configuration.nix
];
};
};
}
Then, enable and configure the service in your configuration.nix.
# configuration.nix
services.prometheus.exporters.qbittorrent = {
enable = true;
# List all your qBittorrent instances here
qbittorrentHosts = [ "http://192.168.1.10:8080" ];
qbittorrentUsername = "your_username";
# Recommended: use a file for your password to keep it safe.
qbittorrentPasswordFile = "/path/to/your/qbit-password.txt";
};
For this, you'll need a PostgreSQL server and have a user/database prepared for the exporter.
# configuration.nix
services.prometheus.exporters.qbittorrent = {
enable = true;
backend.type = "database";
# The default databaseUrl is for a local socket, but using a
# secrets file for the full connection string is a good practice.
backend.databaseUrlFile = "/path/to/your/db-connection-string.txt";
qbittorrentHosts = [ "http://localhost:8080" ];
qbittorrentUsername = "your_username";
qbittorrentPasswordFile = "/path/to/your/qbit-password.txt";
};
The db-connection-string.txt file should contain the URL, e.g., postgres://user:password@host:port/database.
The application can be configured via command-line arguments or the corresponding environment variables.
| Variable | CLI Argument | Default | Description |
|---|---|---|---|
HOST |
--host |
0.0.0.0 |
IP address to bind the exporter to. |
PORT |
--port |
8000 |
Port for the metrics endpoint. |
SCRAPE_INTERVAL |
--scrape-interval |
60 |
How often to scrape qBittorrent (in seconds). |
QBITTORRENT_HOSTS |
--qbittorrent-hosts |
Comma-separated list of qBittorrent URLs. (Required) | |
QBITTORRENT_USERNAME |
--qbittorrent-user |
admin |
qBittorrent WebUI username. |
QBITTORRENT_PASSWORD |
--qbittorrent-pass |
adminadmin |
qBittorrent WebUI password. |
BACKEND |
--backend |
InMemory |
The backend to use (InMemory or Database). |
DATABASE_URL |
--database-url |
(none) |
PostgreSQL connection URL. Required for database backend. |
A variety of metrics are available at the /metrics endpoint.
qbit_upspeed, qbit_dlspeed, qbit_num_leechs, etc.qbit_uploaded, qbit_downloaded, qbit_ratio, qbit_size, qbit_time_active.qbit_category_count, qbit_category_size, qbit_category_uploaded.qbit_tag_count, qbit_tag_size, qbit_tag_uploaded.Add the following job to your prometheus.yml to start scraping:
scrape_configs:
- job_name: "qbittorrent"
scrape_interval: 60s
static_configs:
- targets: ["exporter-host:8000"]
This project is licensed under the GNU GPLv3.