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.
Go to the releases page.
docker pull mrnetops/fastly-exporter
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
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.
USAGE fastly-exporter [flags] FLAGS -api-refresh 1m0s how often to poll api.fastly.com for updated service metadata -api-timeout 15s HTTP client timeout for api.fastly.com requests (5–60s) -debug false Log debug information -endpoint http://127.0.0.1:8080/metrics Prometheus /metrics endpoint -name-exclude-regex ... if set, ignore any service whose name matches this regex -name-include-regex ... if set, only include services whose names match this regex -namespace fastly Prometheus namespace -rt-timeout 45s HTTP client timeout for rt.fastly.com requests (45–120s) -service ... if set, only include this service ID (repeatable) -shard ... if set, only include services whose hashed IDs modulo m equal n-1 (format 'n/m') -subsystem rt Prometheus subsystem -token ... Fastly API token (required; also via FASTLY_API_TOKEN) -version false print version information and exit
By default, all services available to your token will be exported. You can
specify an explicit set of service IDs 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
-name-include-regex '^Production' flag, or reject any service whose name
matches a regex by using the
-name-exclude-regex '.*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
flag. For example, to shard all services between 3 exporters, you would start
each exporter as
fastly-exporter [common flags] -shard 1/3 fastly-exporter [common flags] -shard 2/3 fastly-exporter [common flags] -shard 3/3
Flags which restrict the services that are exported combine with AND semantics.
-service A -service B -name-include-regex 'Foo' would only export
data for service A and/or B if their names also matched "Foo". Or, specifying
-name-include-regex 'Prod' -name-exclude-regex '^test-' would only export data
for services whose names contained "Prod" and did not start with "test-".
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
env FASTLY_API_TOKEN=$MY_TOKEN docker-compose up
Access the Grafana dashboard at http://localhost:3000.