Sign inSign up

mrnetops/fastly-exporter

By mrnetops

•Updated about 5 years ago

Prometheus exporter for the Fastly Real-time Analytics API

Image
2

100K+

mrnetops/fastly-exporter repository overview

⁠fastly-exporter Latest Release Build Status Docker Status

This program consumes from the Fastly Real-time Analytics API⁠ and makes the data available to Prometheus⁠. It should behave like you expect: dynamically adding new services, removing old services, and reflecting changes to service metadata like name and version.

⁠Getting

⁠Binary

Go to the releases page⁠.

⁠Docker

Avaliable as mrnetops/fastly-exporter⁠ from Docker Hub⁠.

docker pull mrnetops/fastly-exporter
⁠Source

If you have a working Go installation, you can install the latest revision from HEAD.

go get github.com/peterbourgon/fastly-exporter/cmd/fastly-exporter

⁠Using

⁠Basic

For simple use cases, all you need is a Fastly API token. See this link⁠ for information on creating API tokens. The token can be provided via the -token flag or the FASTLY_API_TOKEN environment variable.

fastly-exporter -token XXX

This will collect real-time stats for all Fastly services visible to your token, and make them available as Prometheus metrics on 127.0.0.1:8080/metrics.

⁠Filtering services

By default, all services available to your token will be exported. You can specify an explicit set of service IDs to export by using the -service xxx flag. (Service IDs are available at the top of your Fastly dashboard⁠.) You can also include only those services whose name matches a regex by using the -service-whitelist '^Production' flag, or skip any service whose name matches a regex by using the -service-blacklist '.*TEST.*' flag.

For tokens with access to a lot of services, it's possible to "shard" the services among different instances of the fastly-exporter by using the -service-shard flag. For example, to shard all services between 3 exporters, you would start each exporter as

fastly-exporter [common flags] -service-shard 1/3
fastly-exporter [common flags] -service-shard 2/3
fastly-exporter [common flags] -service-shard 3/3
⁠Filtering exported metrics

By default, all metrics provided by the Fastly real-time stats API are exported as Prometheus metrics. You can export only those metrics whose name matches a regex by using the -metric-whitelist 'bytes_total$' flag, or elide any metric whose name matches a regex by using the -metric-blacklist imgopto flag.

⁠Filter semantics

All flags that restrict services or metrics are repeatable. Repeating the same flag causes its condition to be combined with OR semantics. For example, -service A -service B would include both services A and B (but not service C). Or, -service-blacklist Test -service-blacklist Staging would skip any service whose name contained Test or Staging.

Different flags (for the same filter target) combine with AND semantics. For example, -metric-whitelist 'bytes_total$' -metric-blacklist imgopto would only export metrics whose names ended in bytes_total, but didn't include imgopto.

⁠Docker

This repo contains a Dockerfile if you want to build and package it yourself. You can also use a third-party Docker image.

docker run -p 8080:8080 mrnetops/fastly-exporter -token $MY_TOKEN

This repo also contains a Docker Compose⁠ file, which boots up a full fastly-exporter + Prometheus⁠ + Grafana⁠ + Fastly dashboard stack.

env FASTLY_API_TOKEN=$MY_TOKEN docker-compose up

Access the Grafana dashboard at http://localhost:3000⁠.

Fastly Dashboard in Grafana

Tag summary

Content type

Image

Digest

Size

6.7 MB

Last updated

about 5 years ago

docker pull mrnetops/fastly-exporter