cloudflare-exporter
A Prometheus exporter for Cloudflare Load Balancers
Requirements
- Go
- Cloudflare Load Balancing subscription
Installation
$ go build
# Port number (required)
export PORT=8080
# Cloudflare API Key and API email (optional; either CF_API_TOKEN, or CF_API_KEY and CF_API_EMAI are required)
export CF_API_KEY=
export CF_API_EMAIL=
# Cloudflare API Token (optional; either CF_API_TOKEN, or CF_API_KEY and CF_API_EMAI are required)
export CF_API_TOKEN=
Usage
$ ./cloudflare-exporter
Prometheus Configuration
The Cloudflare exporter needs the name of pools to be passed which can be
configured by relabelling in a similar way to the blackbox exporter.
Example config:
scrape_configs:
- job_name: cloudflare
static_configs:
- targets:
- pool01 # Name of Cloudflare pool to check for.
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:8080 # The cloudflare exporter's real hostname:port.
Example result:
# HELP cloudflare_origin_health Result of health check
# TYPE cloudflare_origin_health gauge
cloudflare_origin_health{code="200",health_region="NEAS",origin_address="www01.example.com",pool_name="pool01"} 1
cloudflare_origin_health{code="503",health_region="NEAS",origin_address="www02.example.com",pool_name="pool01"} 0
# HELP cloudflare_origin_rtt_seconds RTT to the pool origin
# TYPE cloudflare_origin_rtt_seconds gauge
cloudflare_origin_rtt_seconds{code="200",health_region="NEAS",origin_address="www01.example.com",pool_name="pool01"} 0.0653
cloudflare_origin_rtt_seconds{code="503",health_region="NEAS",origin_address="www02.example.com",pool_name="pool01"} 0
Spec
Status |
Condition |
200 |
Success. |
400 |
Target is not specified. |
500 |
Unexpected error calling Cloudflare API. |