Sign inSign up

jlentink/cloudflare-exporter

By jlentink

•Updated 7 months ago

Prometheus exporter for Cloudflare zone analytics. Auto-discovers all zones via API token.

Image
Security
Developer tools
Monitoring & observability
0

1.4K

jlentink/cloudflare-exporter repository overview

⁠Cloudflare Prometheus Exporter

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.

⁠Quick Start

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']

⁠Metrics

MetricDescription
cloudflare_requests_totalTotal requests
cloudflare_requests_cached_totalCached requests
cloudflare_requests_uncached_totalUncached requests
cloudflare_requests_cache_hit_ratioCache hit ratio (0–1)
cloudflare_requests_by_status_totalRequests by HTTP status code
cloudflare_requests_by_country_totalRequests by country
cloudflare_bandwidth_bytes_totalTotal bandwidth in bytes
cloudflare_bandwidth_cached_bytes_totalCached bandwidth
cloudflare_bandwidth_uncached_bytes_totalUncached bandwidth
cloudflare_threats_totalThreats blocked
cloudflare_threats_by_country_totalThreats by country
cloudflare_threats_by_type_totalThreats by type
cloudflare_pageviews_totalPageviews
cloudflare_unique_visitors_totalUnique visitors
cloudflare_ssl_requests_encrypted_totalHTTPS requests
cloudflare_ssl_requests_unencrypted_totalHTTP requests
cloudflare_scrape_success1 if last scrape succeeded, 0 if not
cloudflare_last_scrape_timestampUnix timestamp of last scrape

All metrics include zone_id and zone_name labels.

⁠Cloudflare API Token

Create a token at dash.cloudflare.com → Profile → API Tokens with:

  • Zone → Analytics → Read
  • Zone → Zone → Read
  • Zone Resources: All zones

⁠Configuration

VariableDefaultDescription
CF_API_TOKENrequiredCloudflare API token
PORT9199Port to listen on
SCRAPE_INTERVAL_SECONDS60Poll interval in seconds
CF_SINCE_MINUTES1440Analytics window (max 4320 = 3 days)

⁠Endpoints

EndpointDescription
/metricsPrometheus metrics
/healthHealth check

⁠Notes

  • Uses the Cloudflare GraphQL Analytics API — the old REST /analytics/dashboard endpoint is deprecated
  • Free tier supports up to 3 days of analytics history
  • Metrics represent totals over the configured time window, not a live point-in-time value
  • A scrape interval of 60 seconds is recommended

Tag summary

Content type

Image

Digest

sha256:eb3927ce7…

Size

3.6 MB

Last updated

7 months ago

docker pull jlentink/cloudflare-exporter