Prometheus exporter for Backblaze B2 bucket usage metrics
  • Python 92.5%
  • Shell 4.3%
  • Dockerfile 3.2%
Find a file
John Maguire fd461f0c7a
All checks were successful
Build and Push / build (push) Successful in 17s
Add ability to monitor all buckets
2026-04-15 02:26:43 -04:00
.forgejo/workflows Add OCI labels 2026-04-15 02:25:40 -04:00
.gitignore Initial commit: B2 usage Prometheus exporter 2026-03-05 04:00:40 +00:00
Dockerfile Initial commit: B2 usage Prometheus exporter 2026-03-05 04:00:40 +00:00
entrypoint.sh Initial commit: B2 usage Prometheus exporter 2026-03-05 04:00:40 +00:00
exporter.py Add ability to monitor all buckets 2026-04-15 02:26:43 -04:00
README.md Add ability to monitor all buckets 2026-04-15 02:26:43 -04:00

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