- Overview
- Quick Start
- Architecture
- Components
- Accessing Dashboards
- Available Dashboards
- Understanding Metrics
- Custom Queries
- Troubleshooting
- Advanced Configuration
- FAQ
The monitoring stack provides comprehensive visibility into your torrent VPN system using industry-standard observability tools:
- Prometheus: Time-series database for metrics collection
- Grafana: Visualization platform for creating dashboards
- qBittorrent Exporter: Torrent-specific metrics (speeds, peers, ratios)
- cAdvisor: Container resource metrics (CPU, memory, network)
- Performance Monitoring: Track download/upload speeds, bandwidth usage
- Resource Management: Monitor CPU, memory, and network usage per container
- Health Tracking: VPN uptime, container restarts, connection stability
- Trend Analysis: Historical data for capacity planning and optimization
- Troubleshooting: Identify bottlenecks and performance issues
Add to .env (or keep defaults from .env.example):
# Monitoring Configuration (Optional)
GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=admin # CHANGE THIS!
PROMETHEUS_PORT=9090
GRAFANA_PORT=3000
CADVISOR_PORT=8081# Start entire stack with monitoring enabled
docker compose --profile monitoring up -d
# Or start monitoring for existing stack
docker compose --profile monitoring up -d prometheus grafana qbittorrent-exporter cadvisor- Open browser: http://localhost:3000
- Login with credentials from
.env(default: admin/admin) - Browse pre-configured dashboards:
- System - Container Resources
- qBittorrent - Torrent Metrics
- VPN - Gluetun Status
- Open browser: http://localhost:9090
- Go to Status → Targets
- Verify all targets show "UP" status:
- prometheus (self-monitoring)
- cadvisor (container metrics)
- qbittorrent (torrent metrics via exporter)
┌─────────────────────────────────────────────────────────────────┐
│ Monitoring Architecture │
└─────────────────────────────────────────────────────────────────┘
┌──────────────┐
│ Grafana │ ← User accesses dashboards (port 3000)
│ (Dashboards)│
└──────┬───────┘
│ Queries metrics
▼
┌──────────────┐
│ Prometheus │ ← Scrapes metrics every 15s (port 9090)
│ (Metrics DB)│
└──────┬───────┘
│ Scrapes
│
┌──────┴────────────────────────────────────────┐
│ │
▼ ▼
┌─────────────┐ ┌──────────────┐
│ cAdvisor │ │ qBittorrent │
│ (Container │ │ Exporter │
│ Metrics) │ │ (Torrent │
│ │ │ Metrics) │
└─────┬───────┘ └──────┬───────┘
│ Monitors │ Queries
│ Docker containers │ qBittorrent API
▼ ▼
┌─────────────────────────────────────────────────────────┐
│ Docker Containers (Gluetun, qBittorrent) │
└─────────────────────────────────────────────────────────┘
- cAdvisor monitors all Docker containers (CPU, memory, network, disk)
- qBittorrent Exporter polls qBittorrent's Web API for torrent metrics
- Prometheus scrapes metrics from cAdvisor and qBittorrent Exporter every 15 seconds
- Grafana queries Prometheus and displays metrics in dashboards
- User views real-time and historical data in Grafana web UI
Purpose: Metrics collection and storage
Access: http://localhost:9090
Features:
- Time-series database for metrics
- 30-day retention period (configurable)
- PromQL query language for analysis
- Built-in expression browser and graphing
Configuration: config/prometheus/prometheus.yml
Data Location: prometheus-data Docker volume
Purpose: Metrics visualization
Access: http://localhost:3000
Default Credentials: admin/admin (configured in .env)
Features:
- Pre-configured Prometheus datasource
- Three pre-built dashboards
- Dashboard customization and creation
- Alerting capabilities (optional)
- User management
Configuration:
- Datasources:
config/grafana/provisioning/datasources/ - Dashboards:
config/grafana/provisioning/dashboards/ - Dashboard JSON:
config/grafana/dashboards/
Data Location: grafana-data Docker volume
Purpose: Export qBittorrent metrics to Prometheus format
Image: caseyscarborough/qbittorrent-exporter
Metrics Endpoint: http://gluetun:17871/metrics (runs on Gluetun's network)
Metrics Provided:
qbittorrent_torrents_count- Total number of torrentsqbittorrent_download_speed_bytes- Current download speed (bytes/sec)qbittorrent_upload_speed_bytes- Current upload speed (bytes/sec)qbittorrent_total_download_bytes- Total data downloadedqbittorrent_total_upload_bytes- Total data uploadedqbittorrent_global_ratio- Upload/download ratio
Authentication: Uses qBittorrent credentials from .env
Purpose: Container resource monitoring
Image: gcr.io/cadvisor/cadvisor
Access: http://localhost:8081
Metrics Endpoint: http://cadvisor:8080/metrics
Metrics Provided:
container_cpu_usage_seconds_total- CPU usage per containercontainer_memory_usage_bytes- Memory usage per containercontainer_network_receive_bytes_total- Network RX per containercontainer_network_transmit_bytes_total- Network TX per containercontainer_start_time_seconds- Container start time (for uptime calculation)container_last_seen- Last time container was seen (for restart detection)
Limitations: Requires privileged mode on macOS for full disk metrics
- Access Grafana: http://localhost:3000
- Login: Use credentials from
.env(default: admin/admin) - Change Password (recommended): Grafana will prompt on first login
- Browse Dashboards:
- Click Dashboards (icon on left sidebar)
- Open folder: Torrent VPN Monitoring
- Select a dashboard
- System Dashboard: http://localhost:3000/d/torrent-vpn-system
- qBittorrent Dashboard: http://localhost:3000/d/torrent-vpn-qbittorrent
- VPN Dashboard: http://localhost:3000/d/torrent-vpn-gluetun
- Main UI: http://localhost:9090
- Targets Status: http://localhost:9090/targets
- Service Discovery: http://localhost:9090/service-discovery
Purpose: Monitor Docker container resource usage
Panels:
- Container CPU Usage (%) - CPU utilization per container
- Container Memory Usage - Memory consumption per container
- Container Network I/O - Network RX/TX per container
Use Cases:
- Identify resource-heavy containers
- Plan Docker Desktop resource allocation
- Detect memory leaks or CPU spikes
Key Metrics:
- Gluetun CPU: Should be low (< 5%) during normal operation
- qBittorrent CPU: Higher during active downloads
- Memory: qBittorrent typically uses 200-500MB
Purpose: Monitor torrent activity and performance
Panels:
- Total Torrents - Number of torrents in qBittorrent
- Download Speed - Current download rate
- Upload Speed - Current upload rate
- Global Ratio - Overall upload/download ratio
- Transfer Speeds Over Time - Download/upload speed graph
- Torrent Count Over Time - Historical torrent count
- Total Data Transferred - Cumulative up/down totals
Use Cases:
- Monitor download/upload performance
- Track seeding ratios
- Identify bandwidth usage patterns
- Verify VPN speed impact
Thresholds:
- Global Ratio: Green > 1.0, Yellow 0.5-1.0, Red < 0.5
- Speeds: Varies by VPN provider and connection
Purpose: Monitor VPN connection health and stability
Panels:
- VPN Connection Status - UP/DOWN indicator
- VPN Uptime - Time since last restart
- Container Restarts - Number of recent restarts
- VPN Network Throughput - RX/TX through VPN tunnel
- VPN Container CPU Usage - Gluetun CPU utilization
- VPN Container Memory Usage - Gluetun memory consumption
Use Cases:
- Verify VPN is connected and stable
- Detect frequent reconnections (potential VPN issues)
- Monitor VPN throughput vs. qBittorrent speeds
- Troubleshoot VPN performance
Indicators:
- Status GREEN = VPN connected and healthy
- Status RED = VPN down or container stopped
- Frequent restarts = Investigate VPN provider or config
-
Gauge: Current value (e.g., CPU usage, memory usage)
- Value can go up or down
- Shows snapshot at query time
-
Counter: Cumulative value (e.g., total bytes downloaded)
- Value only increases
- Use
rate()function to see per-second change
-
Summary/Histogram: Distribution of values (less common in this stack)
Convert counter to per-second rate:
rate(container_cpu_usage_seconds_total[5m])
[5m]= Look back 5 minutes- Returns average per-second rate over that window
CPU usage as percentage:
rate(container_cpu_usage_seconds_total{name="gluetun"}[5m]) * 100
Bytes per second to megabits per second:
rate(container_network_receive_bytes_total[5m]) * 8 / 1000000
Access Prometheus UI (http://localhost:9090) and try these queries:
time() - container_start_time_seconds{name="gluetun"}
qbittorrent_download_speed_bytes / 1000000
count(container_last_seen > 0)
(container_memory_usage_bytes / container_spec_memory_limit_bytes) * 100
rate(container_network_receive_bytes_total{name="gluetun"}[1m]) * 8 / 1000000
Symptoms: Dashboards are empty, Prometheus targets are "DOWN"
Diagnosis:
# Check Prometheus logs
docker logs prometheus
# Check Prometheus targets
curl http://localhost:9090/api/v1/targetsSolutions:
-
Verify monitoring profile is active:
docker compose --profile monitoring ps # Should show prometheus, grafana, cadvisor, qbittorrent-exporter -
Check Prometheus configuration:
# Validate syntax docker exec prometheus promtool check config /etc/prometheus/prometheus.yml
-
Restart Prometheus:
docker restart prometheus
Symptoms: qBittorrent dashboard shows "No Data"
Diagnosis:
# Check exporter logs
docker logs qbittorrent-exporter
# Test qBittorrent API manually
docker exec -it gluetun wget -qO- http://localhost:8080/api/v2/app/versionSolutions:
-
Verify qBittorrent credentials:
# Check .env file grep QBITTORRENT_USER .env grep QBITTORRENT_PASS .env -
Verify exporter can reach qBittorrent:
# Exporter runs on gluetun network, should reach localhost:8080 docker logs qbittorrent-exporter 2>&1 | grep -i "error\|auth\|connection"
-
Restart exporter:
docker restart qbittorrent-exporter
Symptoms: Dashboards show "Data source prometheus not found"
Diagnosis:
# Check Grafana logs
docker logs grafana
# Check datasource provisioning
docker exec grafana ls -la /etc/grafana/provisioning/datasources/Solutions:
-
Verify Prometheus datasource:
- Login to Grafana: http://localhost:3000
- Go to Configuration → Data Sources
- Should see "Prometheus" with green indicator
-
Manually add datasource (if missing):
- Configuration → Data Sources → Add data source
- Select Prometheus
- URL:
http://prometheus:9090 - Click Save & Test
-
Restart Grafana:
docker restart grafana
Symptoms: System dashboard shows no container metrics
Diagnosis:
# Check cAdvisor logs
docker logs cadvisor
# Test cAdvisor endpoint
curl -s http://localhost:8081/metrics | grep container_cpu_usage_seconds_totalSolutions:
-
macOS-specific: cAdvisor may have limited metrics on macOS Docker Desktop
- Some metrics (disk I/O) are not available on macOS
- CPU and memory should still work
-
Verify privileged mode:
docker inspect cadvisor | grep Privileged # Should show "Privileged": true
-
Restart cAdvisor:
docker restart cadvisor
Symptoms: Prometheus or Grafana consuming excessive memory
Solutions:
-
Reduce Prometheus retention: Edit
docker-compose.yml:command: - '--storage.tsdb.retention.time=7d' # Reduce from 30d to 7d
-
Increase scrape interval: Edit
config/prometheus/prometheus.yml:global: scrape_interval: 30s # Increase from 15s to 30s
-
Restart services:
docker compose --profile monitoring restart
Edit config/prometheus/prometheus.yml:
# Global default (applies to all jobs unless overridden)
global:
scrape_interval: 15s
# Per-job override
scrape_configs:
- job_name: 'qbittorrent'
scrape_interval: 10s # More frequent for torrent metricsEdit docker-compose.yml → prometheus → command:
command:
- '--storage.tsdb.retention.time=7d' # 7 days
- '--storage.tsdb.retention.size=5GB' # Or size-based- Create dashboard in Grafana UI
- Export JSON:
- Dashboard Settings → JSON Model → Copy
- Save to file:
# Save to config/grafana/dashboards/custom-dashboard.json - Restart Grafana:
docker restart grafana
Warning: Only do this on trusted networks!
Edit docker-compose.yml:
prometheus:
ports:
- "0.0.0.0:${PROMETHEUS_PORT:-9090}:9090" # Expose to LAN
grafana:
ports:
- "0.0.0.0:${GRAFANA_PORT:-3000}:3000" # Expose to LANAccess from other devices: http://YOUR_MAC_IP:3000
A: Depends on retention period and scrape interval:
- Prometheus: ~50-100MB per day (30-day retention = ~3GB)
- Grafana: ~50MB for dashboards and config
- Total: ~3-4GB for default configuration
A: No, monitoring overhead is minimal:
- cAdvisor: < 1% CPU, ~50MB RAM
- Prometheus: < 2% CPU, ~200MB RAM
- Grafana: < 1% CPU, ~100MB RAM
- qBittorrent Exporter: < 0.5% CPU, ~20MB RAM
A: Yes, stop individual services:
# Keep Prometheus/Grafana, disable cAdvisor
docker stop cadvisor
# Or remove from docker-compose.yml temporarilyA: Back up Docker volumes:
# Backup Grafana dashboards
docker run --rm -v torrent-vpn-stack_grafana-data:/data -v $(pwd):/backup ubuntu tar czf /backup/grafana-backup.tar.gz /data
# Backup Prometheus data
docker run --rm -v torrent-vpn-stack_prometheus-data:/data -v $(pwd):/backup ubuntu tar czf /backup/prometheus-backup.tar.gz /dataA: Yes, Grafana supports alerting:
- Grafana Alerting (built-in): Configure in Grafana UI
- Prometheus Alertmanager (advanced): Add alertmanager service
Example alert: Notify when VPN goes down
- See Grafana docs: https://grafana.com/docs/grafana/latest/alerting/
A: Gluetun's HTTP API returns JSON (not Prometheus metrics). For richer VPN metrics, consider:
- Custom Prometheus exporter for Gluetun
- Parse Gluetun logs for connection events
- Use cAdvisor container metrics as proxy
A: Yes! The monitoring stack is generic:
- Point Prometheus at any
/metricsendpoint - Create dashboards for any Prometheus data source
- Isolated in Docker network, can run alongside other services
- Prometheus Documentation: https://prometheus.io/docs/
- Grafana Documentation: https://grafana.com/docs/grafana/latest/
- qBittorrent Exporter: https://github.com/caseyscarborough/qbittorrent-exporter
- cAdvisor: https://github.com/google/cadvisor
- PromQL Guide: https://prometheus.io/docs/prometheus/latest/querying/basics/
- Grafana Dashboards: https://grafana.com/grafana/dashboards/
Need Help? Check the main troubleshooting guide or open an issue on GitHub.