cloudflare_exporter
Prometheus metrics exporter for Cloudflare Analytics
Description
Prometheus metrics exporter for Cloudflare Analytics.
This piece of software has one mission: gather Cloudflare Site analytics from the Cloudflare API, and present them in Prometheus' Exposition format, for Prometheus to scrape.
Usage
Considerations
- Tune your configuration. All configuration is done through environment variables:
CLOUDFLARE_EMAIL
: (optional) email used for Cloudflare API email authenticationCLOUDFLARE_KEY
: (optional) key used for Cloudflare API email authenticationCLOUDFLARE_TOKEN
: (optional) token used for Cloudflare API token authenticationCLOUDFLARE_USER_SERVICE_KEY
: (optional) key used for Cloudflare API user service key authenticationCLOUDFLARE_ZONES
: (required) comma-separated list of zone names to scrape for metrics (e.g.example.com,example.org
)CLOUDFLARE_ACCOUNTS
: (optional) comma-separated list of Access account IDs to scrape for metricsCLOUDFLARE_SCRAPE_ANALYTICS_SINCE
: (defaults to24h
)since
parameter of calls to the Cloudflare Analytics APIEXPORTER_LISTEN_ADDR
: (defaults to127.0.0.1:9199
) address for the exporter to bind to
Note: beware of rate limiting! Cloudflare's API has a base limit of 1200 requests every 5 minutes. I recommend configuring your Prometheis to scrape cloudflare_exporter
once every 1-5 minutes.
With the prebuilt container image
Available on Docker Hub as docker.io/ricardbejarano/cloudflare_exporter
:
Also available on Quay as quay.io/ricardbejarano/cloudflare_exporter
:
Any of both registries will do, example:
docker run -it -p 9199:9199 -e CLOUDFLARE_TOKEN="***" -e CLOUDFLARE_ZONES="example.com,example.org" quay.io/ricardbejarano/cloudflare_exporter
Building the container image from source
First clone the repository, and cd
into it:
docker build -t cloudflare_exporter .
Now run it:
docker run -it -p 9199:9199 -e CLOUDFLARE_TOKEN="***" -e CLOUDFLARE_ZONES="example.com,example.org" cloudflare_exporter
Building the binary from source
First clone the repository, and cd
into it.
make
Now run it:
export CLOUDFLARE_TOKEN="***" # WARNING: remember to erase this from your Bash history
export CLOUDFLARE_ZONES="example.com,example.org"
./bin/cloudflare_exporter
FAQs
wehkamp/docker-prometheus-cloudflare-exporter?
What are the differences withcloudflare_exporter
scrapes metrics from the Analytics Dashboard API, available to all Cloudflare customers for freecloudflare_exporter
is not strictly tied to Docker (there's a Docker image, though, see Usage)cloudflare_exporter
is written in Go, instead of Python
criteo/cloudflare-exporter?
What are the differences withcloudflare_exporter
scrapes metrics from the Analytics Dashboard API, available to all Cloudflare customers for freecloudflare_exporter
is written in Go, instead of Python
But does it support pulling analytics by colocation like the others?
Not at the moment, as I require an Enterprise account for development and I don't have one. Feel free to contribute that feature!
Web Analytics?
Does it support CloudflareI finished writing cloudflare_exporter
exactly 1 day before Cloudflare announced their Web Analytics service is now available for free.
That said, I'd love to include support for that. Once the API and the Go API client library support it, I will integrate that into cloudflare_exporter
. Last I checked (Dec 9th, 2020) neither support Web Analytics yet.
What will happen when Cloudflare deprecates their Analytics REST API on March 1st, 2021?
I expect Cloudflare to update their official Go API client library to support the new Analytics GraphQL API before deprecation on March 1st, 2020. I also expect the Go API client library not to change its interface in the process, but I will fix whatever incompatibilities surge during the transition, if any.
cloudflare_exporter
?
What features are coming for At this stage, development for cloudflare_exporter
is paused with the following exceptions:
- Bugs in functionality (raise a GitHub Issue)
- Security vulnerabilities (raise a GitHub Issue asking for a GPG public key)
- Third-party contributions (make a pull request)
cloudflare_exporter
be open to merge?
What features would Basically, any usage analytics data that Cloudflare offers over their APIs, including:
- Cloudflare DNS analytics
- Cloudflare Web Analytics
- Cloudflare Argo analytics
- Cloudflare Site Analytics by colocation
- Cloudflare WAF analytics
- Cloudflare Workers KV analytics
- Cloudflare Spectrum analytics
cloudflare_exporter
implement?
What features won't For now, these are the features that have been decided not to be implemented, and the reasoning behind those decisions:
- Pseudo-metrics about site configuration, to monitor changes to Cloudflare Site configuration. Why? This feature is out of scope (aggregated, usage-derived analytics) for this project.
- Preventive rate limiting, to avoid Cloudflare-side rate limiting. Why? There's already one mechanism available to avoid getting rate limited at the Cloudflare level: increasing
scrape_interval
in Prometheus forcloudflare_exporter
.
License
MIT licensed, see LICENSE for more details.