Prometheus exporter for Cloudflare zone analytics. Auto-discovers all zones via API token.
1.4K
Exports Cloudflare zone analytics as Prometheus metrics using the Cloudflare GraphQL Analytics API. Automatically discovers all active zones on your account — no zone IDs needed, just an API token.
services:
cloudflare-exporter:
image: yourname/cloudflare-exporter:latest
ports:
- "9199:9199"
environment:
- CF_API_TOKEN=your_token_here
restart: unless-stopped
Add to your prometheus.yml:
- job_name: cloudflare
scrape_interval: 60s
static_configs:
- targets: ['cloudflare-exporter:9199']
| Metric | Description |
|---|---|
cloudflare_requests_total | Total requests |
cloudflare_requests_cached_total | Cached requests |
cloudflare_requests_uncached_total | Uncached requests |
cloudflare_requests_cache_hit_ratio | Cache hit ratio (0–1) |
cloudflare_requests_by_status_total | Requests by HTTP status code |
cloudflare_requests_by_country_total | Requests by country |
cloudflare_bandwidth_bytes_total | Total bandwidth in bytes |
cloudflare_bandwidth_cached_bytes_total | Cached bandwidth |
cloudflare_bandwidth_uncached_bytes_total | Uncached bandwidth |
cloudflare_threats_total | Threats blocked |
cloudflare_threats_by_country_total | Threats by country |
cloudflare_threats_by_type_total | Threats by type |
cloudflare_pageviews_total | Pageviews |
cloudflare_unique_visitors_total | Unique visitors |
cloudflare_ssl_requests_encrypted_total | HTTPS requests |
cloudflare_ssl_requests_unencrypted_total | HTTP requests |
cloudflare_scrape_success | 1 if last scrape succeeded, 0 if not |
cloudflare_last_scrape_timestamp | Unix timestamp of last scrape |
All metrics include zone_id and zone_name labels.
Create a token at dash.cloudflare.com → Profile → API Tokens with:
Zone → Analytics → ReadZone → Zone → ReadAll zones| Variable | Default | Description |
|---|---|---|
CF_API_TOKEN | required | Cloudflare API token |
PORT | 9199 | Port to listen on |
SCRAPE_INTERVAL_SECONDS | 60 | Poll interval in seconds |
CF_SINCE_MINUTES | 1440 | Analytics window (max 4320 = 3 days) |
| Endpoint | Description |
|---|---|
/metrics | Prometheus metrics |
/health | Health check |
/analytics/dashboard endpoint is deprecatedContent type
Image
Digest
sha256:eb3927ce7…
Size
3.6 MB
Last updated
7 months ago
docker pull jlentink/cloudflare-exporter