Skip to content

Prometheus textfile collector of Internet speedtest statistics

License

Notifications You must be signed in to change notification settings

jhh/prometheus-speedtest-collector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Speedtest Prometheus Exporter

Overview

The Speedtest Prometheus Exporter is a NixOS module that periodically runs speedtest-go network speed tests and exports the results to be used with the Prometheus node-exporter textfile collector. It gathers data like download and upload speeds, latency, and the time the test was executed, then formats and saves this data in a way that Prometheus can scrape.

Metrics

The following metrics will be available for Prometheus to scrape:

  • speedtest_timestamp_seconds: UNIX epoch time of the last speed test.
  • speedtest_download_megabits_per_second: Download speed in megabits per second.
  • speedtest_upload_megabits_per_second: Upload speed in megabits per second.
  • speedtest_latency_seconds: Latency in seconds.

Labels

All metrics are labeled with:

  • id: Unique identifier of the server assigned by speedtest.net.
  • name: Name of the server.
  • sponsor: The sponsor of the server.
  • distance: Distance to the server (in kilometers).

Usage

To use this as a NixOS module, a bare-minimum flake.nix would be as follows:

{
  description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    speedtest.url = "github:jhh/prometheus-speedtest-collector";
    speedtest.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ nixpkgs, speedtest, ... }: {
    nixosConfigurations = {
      hostname = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          home-manager.nixosModules.home-manager
          speedtest.nixosModules.default
          {
            j3ff.watchtower.speedtest.enable = true;
            # optionally set
            # j3ff.watchtower.speedtest.interval = "4h";
            # j3ff.watchtower.speedtest.collectionDir = "/path/to/dir";
          }
        ];
      };
    };
  };
}

About

Prometheus textfile collector of Internet speedtest statistics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published