Run internet speed test and export metrics to Prometheus.
- Pull Docker container:
docker pull jrowe88/speedtest_exporter
- Run in a Docker container (detached). Optionally, specifiy environment parameters to configure ports, interval, and startup delay.
docker run -d -p 9497:9497 --name speedtest_exporter jrowe88/speedtest_exporter
-
Download and install SpeedTest CLI client
-
Install Python 3
-
Copy *.py files to a directory
-
Run script in background
nohup python3 ./speedtest.py &>/dev/null &
- Goto http://localhost:9497/metrics to view metrics
- Change default parameters
Note: SpeedTest downloads and uploads many MB of data over your connection. Do not set the interval (INTERVAL_SECONDS) to be very short unless that is your intention and you understand the consequences to your internet traffic. Default is 1800 seconds, or every 30 minutes. This examples changes port to 9191, delay to 5s and interval to 7200s.
docker run -d -p 9191:9191 --env PORT=9191 --env INTERVAL_SECONDS=7200 --env STARTUPDELAY_SECONDS=5 --name speedtest_exporter jrowe88/speedtest_exporter
- Setting up Prometheus Scraper Config
Add a section similar to the prometheus.yml configuration file (or add another target to an existing job)
...
- job_name: speed
scrape_interval: 240s
metrics_path: /metrics
static_configs:
- targets:
- 192.168.1.3:9497
...
Reload the Prometheus config:
curl -X POST http://192.168.1.3:9497/-/reload
Grafana Dashboard: https://grafana.com/dashboards/12309
Prometheus configuration: https://prometheus.io/docs/prometheus/latest/configuration/configuration/
Copyright @ 2020 Jim Rowe