diff options
author | WilliButz <WilliButz@users.noreply.github.com> | 2021-03-11 19:18:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-11 19:18:29 +0100 |
commit | f5c01cf9d4e744426c938b000e235011f7076929 (patch) | |
tree | f213558b746bb792ddbf374b8bfceede049328d9 | |
parent | 3ceef8186cc4e70149c23e21ffb85ecccbce10aa (diff) | |
parent | 344b02919ee4d4b9ffbd7ebca44f99a8202f9749 (diff) |
Merge pull request #113370 from chkno/prometheus-systemd-exporter-no-flags
prometheus-systemd-exporter: Init at 0.4.0
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/systemd.nix | 18 | ||||
-rw-r--r-- | nixos/tests/prometheus-exporters.nix | 16 | ||||
-rw-r--r-- | pkgs/servers/monitoring/prometheus/systemd-exporter.nix | 25 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 1 |
5 files changed, 61 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 4c24784868539..115ecbf12b5e6 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -53,6 +53,7 @@ let "smokeping" "sql" "surfboard" + "systemd" "tor" "unifi" "unifi-poller" diff --git a/nixos/modules/services/monitoring/prometheus/exporters/systemd.nix b/nixos/modules/services/monitoring/prometheus/exporters/systemd.nix new file mode 100644 index 0000000000000..0514469b8a61e --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/systemd.nix @@ -0,0 +1,18 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let cfg = config.services.prometheus.exporters.systemd; + +in { + port = 9558; + + serviceOpts = { + serviceConfig = { + ExecStart = '' + ${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter \ + --web.listen-address ${cfg.listenAddress}:${toString cfg.port} + ''; + }; + }; +} diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index a97a44e02f1c0..78a3afad0ba33 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -835,6 +835,22 @@ let ''; }; + systemd = { + exporterConfig = { + enable = true; + }; + metricProvider = { }; + exporterTest = '' + wait_for_unit("prometheus-systemd-exporter.service") + wait_for_open_port(9558) + succeed( + "curl -sSf localhost:9558/metrics | grep -q '{}'".format( + 'systemd_unit_state{name="basic.target",state="active",type="target"} 1' + ) + ) + ''; + }; + tor = { exporterConfig = { enable = true; diff --git a/pkgs/servers/monitoring/prometheus/systemd-exporter.nix b/pkgs/servers/monitoring/prometheus/systemd-exporter.nix new file mode 100644 index 0000000000000..96029c99d8c6a --- /dev/null +++ b/pkgs/servers/monitoring/prometheus/systemd-exporter.nix @@ -0,0 +1,25 @@ +{ lib, buildGoModule, fetchFromGitHub, nixosTests }: + +buildGoModule rec { + pname = "systemd_exporter"; + version = "0.4.0"; + + vendorSha256 = "sha256-bYoB0r+d0j3esi/kK2a7/Duup9cf4M3WJjiBNs2+bj8="; + + src = fetchFromGitHub { + owner = "povilasv"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-JDfRHczFnTP9sxA7polUE9qzJhSPIiAU58GBNDYkX4c="; + }; + + passthru.tests = { inherit (nixosTests.prometheus-exporters) systemd; }; + + meta = with lib; { + description = "Exporter for systemd unit metrics"; + homepage = "https://github.com/povilasv/systemd_exporter"; + license = licenses.asl20; + maintainers = with maintainers; [ chkno ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2037857acf9b0..72fdc8cbbc4ec 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18619,6 +18619,7 @@ in prometheus-smokeping-prober = callPackage ../servers/monitoring/prometheus/smokeping-prober.nix { }; prometheus-snmp-exporter = callPackage ../servers/monitoring/prometheus/snmp-exporter.nix { }; prometheus-sql-exporter = callPackage ../servers/monitoring/prometheus/sql-exporter.nix { }; + prometheus-systemd-exporter = callPackage ../servers/monitoring/prometheus/systemd-exporter.nix { }; prometheus-tor-exporter = callPackage ../servers/monitoring/prometheus/tor-exporter.nix { }; prometheus-statsd-exporter = callPackage ../servers/monitoring/prometheus/statsd-exporter.nix { }; prometheus-surfboard-exporter = callPackage ../servers/monitoring/prometheus/surfboard-exporter.nix { }; |