Performs speedtest-cli tests and pushes metrics to Prometheus Pushgateway
Project description
Prometheus Speedtest
Instrument Speedtest.net tests from Prometheus.
Getting Started
These instructions will run prometheus_speedtest
on your system.
Running with Docker
prometheus_speedtest
is available on
Docker Hub :whale:.
docker run --rm -d --name prometheus_speedtest -p 8080:8080/tcp jraviles/prometheus_speedtest:latest
Installing with PyPi
prometheus_speedtest
is also provided as a
PyPi package. It can be
installed with:
pip3 install prometheus_speedtest
Usage
usage: prometheus_speedtest.py [-h] [-p port]
Instrument speedtest.net speedtests from Prometheus.
optional arguments:
-h, --help show this help message and exit
-p port, --port port port to listen on.
Integrating with Prometheus
Example prometheus.yml config
global:
scrape_timeout: 60s
scrape_configs:
- job_name: 'speedtest'
metrics_path: /probe
static_configs:
- targets:
- prometheus_speedtest:8080
Trying it out
An example config has been provided at example/prometheus.yml.
docker network create prometheus_network
docker run --rm -d --net prometheus_network -p 8080:8080/tcp --name prometheus_speedtest \
jraviles/prometheus_speedtest:latest
docker run --rm -d --net prometheus_network -p 9090:9090/tcp --name prometheus \
-v $PWD/example/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:latest
Visit http://localhost:9090, wait for Prometheus to scrape, and issue a query for download_speed_bps. You should see something like this.
Getting Started (Development)
These instructions will get you a copy prometheus_speedtest
up and running on
your local machine for development and testing purposes. See deployment for
instructions on how to deploy prometheus_speedtest
to
PyPi.
Prerequisites
Running locally
-
Ensure packages listed in requirements.txt are installed with
pip
pip3 install -r requirements.txt
-
Run
prometheus_speedtest
python3 prometheus_speedtest.py
Running with Docker
docker build -t prometheus_speedtest:latest .
docker run --rm -d --name prometheus_speedtest -p 8080:8080/tcp prometheus_speedtest:latest
Perform a Speedtest
curl localhost:8080/probe
Or visit http://localhost:8080
Testing
python3 setup.py test
Contributing
Pull requests are welcome. Please adhere to the Google Python style guide.
Please format your contributions with the yapf formatter and lint your code with pylint. A .pylintrc config has been provided.
yapf -i *.py
pylint3 *.py
Deploying to PyPi
python3 setup.py sdist
twine upload dist/*
Authors
- Jean-Ralph Aviles
License
This product is licensed under the Apache 2.0 license. See LICENSE file for details.
Acknowledgments
- Matt Martz speedtest-cli
- The Prometheus team https://prometheus.io
- Testing in Python team http://lists.idyll.org/listinfo/testing-in-python
- Benjamin Staffin python-glog
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for prometheus_speedtest-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d666d081f63d7c63f82a782dffad46105fe857fb0e4921d2bb0c787aa80fecfb |
|
MD5 | 06e7baa614b255ba730698ce43f5d037 |
|
BLAKE2b-256 | b92a79c95cfd63c85bdc71c69ee722cec42dbb40f32099cb27ce7c25cd46336c |