Skip to main content

Performs speedtest-cli tests and pushes metrics to Prometheus Pushgateway

Project description

Prometheus Speedtest

Instrument Speedtest.net tests from Prometheus.

Build Status Docker Build Status PyPI status PyPI version shields.io PyPI license PyPI pyversions

Grafana

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.

Prometheus Query

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

  1. Ensure packages listed in requirements.txt are installed with pip

    pip3 install -r requirements.txt
    
  2. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prometheus_speedtest-0.3.0.tar.gz (4.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page