speedtest-exporter

command module
v0.0.0-...-637e392 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 11 Imported by: 0

README

speedtest-exporter

A Go binary that runs the speedtest.net CLI and exports the returned values so that Prometheus can scrape them.

By default, the speedtest-exporter binary runs a speed test once an hour. The results are exported continuously until the next speed test is run. The --frequency flag can be used to change how often a speed test is run.

Run using Docker

From the project's root directory:

$ docker run ghcr.io/jeffpaine/speedtest-exporter:latest -p 2112:2112

Manual install and run

  1. Install the speedtest CLI
  2. Make sure the speedtest binary is on your system $PATH
  3. Install the speedtest-exporter binary:
    $ go install github.com/jeffpaine/speedtest-exporter@latest
    
  4. Run the binary:
    $ speedtest-exporter
    

Test scrape data

$ curl localhost:2112/metrics  # Adjust 'localhost' as needed

Scraping with Prometheus

Configure Prometheus to scrap the host that speedtest-exporter is running on via port 2112 (default, can be changed via the --port flag). For example in your prometheus.yml:

scrape_configs:
  - job_name: "speedtest"
    metrics_path: /metrics
    static_configs:
      - targets: ["localhost:2112"]  # Adjust 'localhost' as needed

Developer notes

Enable multi-architecture building

Create a docker builder that supports multiple architectures, as the default builder does not (docs):

Before:

$ docker buildx ls
NAME/NODE     DRIVER/ENDPOINT   STATUS    BUILDKIT   PLATFORMS
default*      docker                                 
 \_ default    \_ default       running   v0.15.2    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386

Create a multi-arch builder (info on flags: docs):

$ docker buildx create --name container-builder --driver docker-container --use --bootstrap

After:

$ docker buildx ls
NAME/NODE                DRIVER/ENDPOINT                   STATUS    BUILDKIT   PLATFORMS
container-builder*       docker-container                                       
 \_ container-builder0    \_ unix:///var/run/docker.sock   running   v0.15.2    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
default                  docker                                                 
 \_ default               \_ default                       running   v0.15.2    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
Build and push

Following the GitHub Container Registry docs:

  1. Generate a short lived access token (docs)

  2. Log in via the CLI:

    $ sudo docker login ghcr.io -u jeffpaine --password 'REPLACE_ME'
    
  3. Build and upload

    $ sudo docker buildx build --platform linux/amd64,linux/arm64 --tag ghcr.io/jeffpaine/speedtest-exporter:latest --push .
    

    Note that buildx requires the use of the --push flag when using the --platform flag with multiple architectures: https://github.com/docker/buildx/issues/59.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL