summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorChuck <chuck@intelligence.org>2021-02-16 23:08:45 -0800
committerChuck <chuck@intelligence.org>2021-02-18 09:56:45 -0800
commit83de9e2d12749ab5ed5c855dba8510a04e65ef4a (patch)
treeebaca28f07073d75aeb60bec426b6dbd2b29fc66 /nixos
parentff96a0fa5635770390b184ae74debea75c3fd534 (diff)
downloadnixpkgs-83de9e2d12749ab5ed5c855dba8510a04e65ef4a.tar
nixpkgs-83de9e2d12749ab5ed5c855dba8510a04e65ef4a.tar.gz
nixpkgs-83de9e2d12749ab5ed5c855dba8510a04e65ef4a.tar.bz2
nixpkgs-83de9e2d12749ab5ed5c855dba8510a04e65ef4a.tar.lz
nixpkgs-83de9e2d12749ab5ed5c855dba8510a04e65ef4a.tar.xz
nixpkgs-83de9e2d12749ab5ed5c855dba8510a04e65ef4a.tar.zst
nixpkgs-83de9e2d12749ab5ed5c855dba8510a04e65ef4a.zip
prometheus-systemd-exporter: Init at 0.4.0
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix1
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/systemd.nix18
-rw-r--r--nixos/tests/prometheus-exporters.nix16
3 files changed, 35 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
index 940f2818937..81b6b5931ea 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -51,6 +51,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 00000000000..0514469b8a6
--- /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 89d17c9de8c..53aea4f258a 100644
--- a/nixos/tests/prometheus-exporters.nix
+++ b/nixos/tests/prometheus-exporters.nix
@@ -802,6 +802,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;