Collects CloudFlare analytics and pushes them to CloudWatch metrics.

  • By Skpr
  • Last update: Nov 15, 2022
  • Comments: 1

Cloudflare Metrics

This application queries CloudFlare Analytics API to get key metrics, and pushes them to AWS CloudWatch Metrics.

Current metric collectors are:

  • Cache Statistics


The application requires the following environment variables be set:

  • CLOUDFLARE_ENDPOINT_URL The CloudFlare graphql endpoint e.g.
  • CLOUDFLARE_API_TOKEN Your CloudFlare API token with ReadAnalytics permissions
  • CLOUDFLARE_ZONE_TAG The Zone Tag to query.
  • CLOUDFLARE_HOSTNAME The hostname to filter by.
  • PERIOD_SECONDS The number of seconds between metric collection (minimum 60 seconds).
  • METRICS_NAMESPACE The AWS CloudWatch Metric namespace to use.


Copy local.env.dist to local.env and set variables.

Use the following make commands:

make build
make lint
make vet
make test


The application is released as a docker image when a new tag is created.

You can test the release process locally using:

goreleaser build --snapshot --rm-dist



  • 1

    Simplify and reduce number of metrics

    Dramatically reduce the number of generated metrics by using less dimensions and fetching less data.

    Also added tests for each collector using http test server.