You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Export Cloudflare metrics to Prometheus. Built on Cloudflare Workers with Durable Objects for stateful metric accumulation.
Features
80+ Prometheus metrics - requests, bandwidth, threats, workers, load balancers, SSL certs, hostname-level analytics, network analytics, and more
Cloudflare Workers - serverless edge deployment
Durable Objects - stateful counter accumulation for proper Prometheus semantics
Background refresh - alarms fetch data every 60s; scrapes return cached data instantly
Rate limiting - 200 req/10s with exponential backoff
Multi-account - automatically discovers and exports all accessible accounts/zones
Runtime config API - change settings without redeployment via REST endpoints
Configurable - zone filtering, metric denylist, label exclusion, custom metrics path, and more
Quick Start
One-Click Deploy
Click the deploy button above. Configure CLOUDFLARE_API_TOKEN as a secret after deployment. Configure BASIC_AUTH_USER and BASIC_AUTH_PASSWORD to protect the exporter with HTTP Basic Auth.
Manual Deployment
git clone https://github.com/cloudflare/cloudflare-prometheus-exporter.git
cd cloudflare-prometheus-exporter
bun install
wrangler secret put CLOUDFLARE_API_TOKEN
bun run deploy
Configuration
Configuration is resolved in order: KV overrides → env vars → defaults. Use the Runtime Config API for dynamic changes without redeployment.
Environment Variables
Set in wrangler.jsonc or via wrangler secret put:
Variable
Default
Description
CLOUDFLARE_API_TOKEN
-
Cloudflare API token (secret)
QUERY_LIMIT
10000
Max results per GraphQL query
SCRAPE_DELAY_SECONDS
300
Delay before fetching metrics (data propagation)
TIME_WINDOW_SECONDS
60
Query time window
METRIC_REFRESH_INTERVAL_SECONDS
60
Background refresh interval
LOG_LEVEL
info
Log level (debug/info/warn/error)
LOG_FORMAT
json
Log format (pretty/json)
ACCOUNT_LIST_CACHE_TTL_SECONDS
600
Account list cache TTL
ZONE_LIST_CACHE_TTL_SECONDS
1800
Zone list cache TTL
SSL_CERTS_CACHE_TTL_SECONDS
1800
SSL cert cache TTL
HEALTH_CHECK_CACHE_TTL_SECONDS
10
Health check cache TTL
EXCLUDE_HOST
false
Exclude host labels from metrics
CF_HTTP_STATUS_GROUP
false
Group HTTP status codes (2xx, 4xx, etc.)
DISABLE_UI
false
Disable landing page (returns 404)
DISABLE_CONFIG_API
false
Disable config API endpoints (returns 404)
METRICS_DENYLIST
-
Comma-separated list of metrics to exclude
CF_ACCOUNTS
-
Comma-separated account IDs to include (default: all)
CF_ZONES
-
Comma-separated zone IDs to include (default: all)
CF_FREE_TIER_ACCOUNTS
-
Comma-separated account IDs using free tier (skips paid-tier metrics)
HOST_METRICS_ALLOWLIST
-
Comma-separated hostnames for hostname-level metrics (max 50). Empty disables. Adds 2 extra GraphQL calls per account per refresh cycle. EXCLUDE_HOST=true also disables.
METRICS_PATH
/metrics
Custom path for metrics endpoint
BASIC_AUTH_USER
-
Username for basic auth (secret, default: no auth, requires BASIC_AUTH_PASSWORD)
BASIC_AUTH_PASSWORD
-
Password for basic auth (secret, default: no auth, requires BASIC_AUTH_USER)
Override configuration at runtime without redeployment. Overrides persist in KV and take precedence over wrangler.jsonc env vars.
Config Keys
Key
Type
Description
queryLimit
number
Max results per GraphQL query
scrapeDelaySeconds
number
Delay before fetching metrics
timeWindowSeconds
number
Query time window
metricRefreshIntervalSeconds
number
Background refresh interval
accountListCacheTtlSeconds
number
Account list cache TTL
zoneListCacheTtlSeconds
number
Zone list cache TTL
sslCertsCacheTtlSeconds
number
SSL cert cache TTL
healthCheckCacheTtlSeconds
number
Health check cache TTL
logFormat
"json" | "pretty"
Log format
logLevel
"debug" | "info" | "warn" | "error"
Log level
cfAccounts
string | null
Comma-separated account IDs (null = all)
cfZones
string | null
Comma-separated zone IDs (null = all)
cfFreeTierAccounts
string
Comma-separated free tier account IDs
metricsDenylist
string
Comma-separated metrics to exclude
excludeHost
boolean
Exclude host labels
httpStatusGroup
boolean
Group HTTP status codes
hostMetricsAllowlist
string
Comma-separated hostnames for hostname-level metrics
Examples
# Get all config
curl https://your-worker.workers.dev/config
# Get single value
curl https://your-worker.workers.dev/config/logLevel
# Set override
curl -X PUT https://your-worker.workers.dev/config/logLevel \
-H "Content-Type: application/json" \
-d '{"value": "debug"}'# Filter to specific zones
curl -X PUT https://your-worker.workers.dev/config/cfZones \
-H "Content-Type: application/json" \
-d '{"value": "zone-id-1,zone-id-2"}'# Reset to env default
curl -X DELETE https://your-worker.workers.dev/config/logLevel
# Reset all overrides
curl -X DELETE https://your-worker.workers.dev/config
Traffic volume metrics across Cloudflare's Network Analytics v2 datasets. All are account-level counters with low-cardinality labels. Datasets that don't apply to an account (e.g. no Magic Transit subscription) return no data.
Requires HOST_METRICS_ALLOWLIST to be set (max 50 hostnames). Disabled when EXCLUDE_HOST=true.
All hostname metrics are gauge snapshots over the lookback window (1h or 2h), not cumulative counters. The window label indicates the lookback period. Hosts with zero traffic in a window will not emit series for that window.
Metric
Type
Labels
Description
cloudflare_zone_hostname_requests
gauge
zone, host, window
Total requests in lookback window
cloudflare_zone_hostname_requests_by_status
gauge
zone, host, status, window
Requests by HTTP status code (raw, e.g. 200/404/500)
Origin response duration in seconds (P50/P95 quantiles)
SSL Certificate Metrics
Metric
Type
Labels
cloudflare_zone_certificate_validation_status
gauge
zone, type, issuer, status
Exporter Info Metrics
Metric
Type
Labels
cloudflare_exporter_up
gauge
-
cloudflare_exporter_errors_total
counter
account_id, error_code
cloudflare_accounts
gauge
-
cloudflare_zones
gauge
-
cloudflare_zones_filtered
gauge
-
cloudflare_zones_processed
gauge
-
cloudflare_zones_skipped_free_tier
gauge
-
Free Tier Zone Limitations
Zones on Cloudflare's Free plan don't have access to the GraphQL Analytics API. The exporter automatically detects and skips free tier zones for metrics that require this API.