Prometheus exporter for Transport for London cycle hire availability data.
Powered by TfL Open Data.
At the time of writing, there are over 700 docking stations. The exporter will expose 4 time series for each one:
# HELP tflcycles_bicycles_available The number of in-service, conventional bikes available for hire.
# TYPE tflcycles_bicycles_available gauge
tflcycles_bicycles_available{station="Stonecutter Street, Holborn"} 2
...
# HELP tflcycles_docks The total number of docks at the station, including those that are out of service.
# TYPE tflcycles_docks gauge
tflcycles_docks{station="Stonecutter Street, Holborn"} 21
...
# HELP tflcycles_docks_available The number of in-service, vacant docks to which a bike can be returned.
# TYPE tflcycles_docks_available gauge
tflcycles_docks_available{station="Stonecutter Street, Holborn"} 19
...
# HELP tflcycles_ebikes_available The number of in-service e-bikes available for hire.
# TYPE tflcycles_ebikes_available gauge
tflcycles_ebikes_available{station="Stonecutter Street, Holborn"} 0
...
Download the latest release for your platform, extract, and invoke:
$ curl -LO https://github.com/gebn/tflcycles_exporter/releases/download/v1.1.2/tflcycles_exporter-1.1.2.linux-amd64.tar.gz
$ tar xf tflcycles_exporter-1.1.2.linux-amd64.tar.gz
$ cd tflcycles_exporter-1.1.2.linux-amd64
$ ./tflcycles_exporter
By default, the exporter will listen on port 9722. Visit http://localhost:9722/stations to see the metrics.
The exporter uses TfL's BikePoint API to retrieve docking station information.
Registration is optional, however it provides success and latency metrics about your API requests.
An application key can be passed in an APP_KEY
environment variable when starting the exporter, and it will be used automatically.
The following steps will be suitable for the majority of Linux users.
-
Extract the release archive to
/opt/tflcycles_exporter
. -
Copy
tflcycles_exporter.service
into/etc/systemd/system
, and open the file in your favourite editor.-
Ensure
User
is set to a suitable value. A dedicated account could be created with:# useradd -s /usr/sbin/nologin -r -M tflcycles_exporter
-
Set
APP_KEY
if desired.
-
-
Execute the following as
root
:systemctl enable tflcycles_exporter.service # start on boot systemctl start tflcycles_exporter.service # launch exporter systemctl status tflcycles_exporter.service # check running smoothly
Images are published to Docker Hub each push.
In a Kubernetes context, the /
endpoint is efficient to serve, so is suitable for liveness and readiness probes.
The exporter exposes its own direct-instrumentation metrics at /metrics
, which can be scraped normally.
TfL data is exposed at /stations
.
Each request to this endpoint will trigger a call to the BikePoint API and render the results as metrics.
The source data is updated at most once per minute, so the scrape interval should not be below 1m
.
Setting it below this will still work, however it will needlessly re-retrieve the same values from TfL's API, and use up your request limit unnecessarily.
scrape_configs:
- job_name: tflcycles-exporter
static_configs:
- targets:
- localhost:9722
- job_name: tflcycles
scrape_interval: 1m
metrics_path: /stations
static_configs:
- targets:
- localhost:9722
If Prometheus is deployed with multiple replicas, and you plan to colocate an exporter instance next to each one, the /metrics
job should not be deduplicated, as these are separate processes.
You may need to use a hostname other than localhost
to ensure distinct label sets.
The /stations
job can be deduplicated safely, as all exporters should return the same thing within a given minute.