Skip to content

Speedtest Exporter


GitHub release (latest by date) GitHub Repo stars Docker Pulls GitHub Workflow Status

Speedtest exporter is a Prometheus exporter written in Python using the official Speedtest CLI made by Ookla.

It will measure your:

  • Download Speed
  • Upload Speed
  • Ping
  • Jitter

Setting up the Exporter

Docker

Image location:

Container Registry Image
Github Container ghcr.io/miguelndecarvalho/speedtest-exporter
Dockr Hub miguelndecarvalho/speedtest-exporter
Warning

I recommend you to use Github Container as you won't face any pull limit.

Deploying:

docker run -d \
  --name=speedtest-exporter \
  -p 9798:9798 \
  -e SPEEDTEST_PORT=<speedtest-port> #optional \
  -e SPEEDTEST_SERVER=<speedtest-serverid> #optional \
  --restart unless-stopped \
  miguelndecarvalho/speedtest-exporter
version: "3.0"
services:
  speedtest-exporter:
    image: miguelndecarvalho/speedtest-exporter
    container_name: speedtest-exporter
    environment:
      - SPEEDTEST_PORT=<speedtest-port> #optional
      - SPEEDTEST_SERVER=<server-id> #optional
    ports:
      - 9798:9798
    restart: unless-stopped
Tip

You can pull a specific version of the exporter. For example: miguelndecarvalho/speedtest-exporter:v3.1 Get the changelog here

Environments

Env Optional Description Default Example
SPEEDTEST_PORT Sets the Port where exporter listens 9798 9800
SPEEDTEST_SERVER Set the Server from where the tests will be made Best Server 31309 - MEO PT
Tip

To get the ServerID to use in the Env SPEEDTEST_SERVER you can use this Server list to get the IDs.

Warning

When you set the Env SPEEDTEST_PORT, don't forget to publish the right port.

-p <SPEEDTEST_PORT>:<SPEEDTEST_PORT>
ports:
  - <SPEEDTEST_PORT>:<SPEEDTEST_PORT>
Danger

We strongly discourage you from setting a specific server. If the server that you are using to make the tests stops working, your exporter won't be able to do the tests and you won't get the metrics.

Manual

Requirements

You will need to have:

Steps to install

  1. Clone repo - git clone https://github.com/MiguelNdeCarvalho/speedtest-exporter.git
  2. Enter the repo folder - cd speedtest-exporter
  3. Install python modules - pip install -r src/requirements.txt
  4. Execute the exporter - python src/exporter.py

Then just access the page http://localhost:9800/ and you will have the exporter page.

Tip

If you wanna set the Port and the default Server just use these Envs to set it

Example:

export SPEEDTEST_PORT=9800; export SPEEDTEST_SERVER=1758; python src/exporter.py

Add exporter to Prometheus

To add the Speedtest Exporter to your Prometheus just add this to your prometheus.yml:

- job_name: 'speedtest-exporter'
  scrape_interval: <time-between-tests>
  scrape_timeout: 1m
  static_configs:
    - targets: ['<ip-of-exporter-machine>:<port-where-exporter-is-listenning>']

Real example where the tests will be done every hour:

- job_name: 'speedtest-exporter'
  scrape_interval: 1h
  scrape_timeout: 1m
  static_configs:
    - targets: ['speedtest-exporter:9798']

Grafana Dashboard

The Grafana Dashboard can be found here or you can get the file here

Fig 1. Grafana Dashboard

FAQ

Question

How can I set the time between the Scrapes?

That is configured on your prometheus.yml. In this example the test will be made every hour scrape_interval: 1h.

Question

Why isn't it working?

If you set the tests to be made every hour (scrape_interval: 1h), Prometheus will only do the first scrape after it is up for an hour.

Question

How can I test the exporter without Prometheus?

You can just acess access it with your browser http://ip:9798/ and you should be prompted with a welcome screen. If you access http://ip:9798/metrics it should take around 30 seconds and then you will be prompted with all the metrics.

Changelog

You can check the changelog here