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
58 Prometheus metrics - requests, bandwidth, threats, workers, load balancers, SSL certs, 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 - 40 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.
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)
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
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
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.