summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorSarah Brofeldt <sarah@qtr.dk>2020-06-18 07:46:52 +0200
committerSarah Brofeldt <sarah@qtr.dk>2020-06-18 11:13:25 +0200
commit344e64a4d970a180fc0bc1054cb5fd503dc1daa8 (patch)
treefdbec4cd36ea537afd783d95377df983628a293a /nixos
parentac3a50122bb33ee72a0a243673bf2c619ec86486 (diff)
downloadnixpkgs-344e64a4d970a180fc0bc1054cb5fd503dc1daa8.tar
nixpkgs-344e64a4d970a180fc0bc1054cb5fd503dc1daa8.tar.gz
nixpkgs-344e64a4d970a180fc0bc1054cb5fd503dc1daa8.tar.bz2
nixpkgs-344e64a4d970a180fc0bc1054cb5fd503dc1daa8.tar.lz
nixpkgs-344e64a4d970a180fc0bc1054cb5fd503dc1daa8.tar.xz
nixpkgs-344e64a4d970a180fc0bc1054cb5fd503dc1daa8.tar.zst
nixpkgs-344e64a4d970a180fc0bc1054cb5fd503dc1daa8.zip
nixos/prometheus-redis-exporter: init
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix1
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/redis.nix19
-rw-r--r--nixos/tests/prometheus-exporters.nix14
3 files changed, 34 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
index 0318acae50f..29f402b212f 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -39,6 +39,7 @@ let
     "node"
     "postfix"
     "postgres"
+    "redis"
     "rspamd"
     "snmp"
     "surfboard"
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/redis.nix b/nixos/modules/services/monitoring/prometheus/exporters/redis.nix
new file mode 100644
index 00000000000..befbcb21f76
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/redis.nix
@@ -0,0 +1,19 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let
+  cfg = config.services.prometheus.exporters.redis;
+in
+{
+  port = 9121;
+  serviceOpts = {
+    serviceConfig = {
+      ExecStart = ''
+        ${pkgs.prometheus-redis-exporter}/bin/redis_exporter \
+          -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+          ${concatStringsSep " \\\n  " cfg.extraFlags}
+      '';
+    };
+  };
+}
diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix
index 4dbd6431222..75c4ca12db2 100644
--- a/nixos/tests/prometheus-exporters.nix
+++ b/nixos/tests/prometheus-exporters.nix
@@ -475,6 +475,20 @@ let
       '';
     };
 
+    redis = {
+      exporterConfig = {
+        enable = true;
+      };
+      metricProvider.services.redis.enable = true;
+      exporterTest = ''
+        wait_for_unit("redis.service")
+        wait_for_unit("prometheus-redis-exporter.service")
+        wait_for_open_port(6379)
+        wait_for_open_port(9121)
+        wait_until_succeeds("curl -sSf localhost:9121/metrics | grep -q 'redis_up 1'")
+      '';
+    };
+
     rspamd = {
       exporterConfig = {
         enable = true;