Prometheus exporter for Backblaze B2 bucket usage metrics
- Python 92.5%
- Shell 4.3%
- Dockerfile 3.2%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| .gitignore | ||
| Dockerfile | ||
| entrypoint.sh | ||
| exporter.py | ||
| README.md | ||
b2-usage-exporter
Prometheus exporter for Backblaze B2 bucket usage metrics. Uses rclone under the hood to query bucket sizes on a configurable interval and exposes them at /metrics.
Metrics
b2_bucket_size_bytes{bucket="my-bucket"} 214748364800
b2_bucket_file_count{bucket="my-bucket"} 147
b2_scrape_duration_seconds 2.5
b2_scrape_success 1
Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
B2_ACCOUNT_ID |
Yes | — | Backblaze B2 application key ID |
B2_ACCOUNT_KEY |
Yes | — | Backblaze B2 application key |
B2_BUCKETS |
Yes | — | Comma-separated list of bucket names, or * to discover and scrape all buckets in the account |
SCRAPE_INTERVAL |
No | 1h |
How often to refresh (30m, 1h, 300s, etc.) |
PORT |
No | 9110 |
Port for the metrics HTTP server |
Docker
docker build -t b2-usage-exporter .
docker run -d \
-e B2_ACCOUNT_ID=your_key_id \
-e B2_ACCOUNT_KEY=your_app_key \
-e B2_BUCKETS=bucket1,bucket2 \
-p 9110:9110 \
b2-usage-exporter
docker-compose
services:
b2-exporter:
build: .
restart: unless-stopped
environment:
B2_ACCOUNT_ID: ${B2_ACCOUNT_ID}
B2_ACCOUNT_KEY: ${B2_ACCOUNT_KEY}
B2_BUCKETS: "bucket1,bucket2"
SCRAPE_INTERVAL: "1h"
ports:
- "9110:9110"
Add to your Prometheus config:
scrape_configs:
- job_name: b2
static_configs:
- targets: ["b2-exporter:9110"]
License
MIT