Skip to content

Commit

Permalink
nixos/prometheus-redis-exporter: init
Browse files Browse the repository at this point in the history
  • Loading branch information
srhb committed Jun 18, 2020
1 parent ac3a501 commit 344e64a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/modules/services/monitoring/prometheus/exporters.nix
Expand Up @@ -39,6 +39,7 @@ let
"node"
"postfix"
"postgres"
"redis"
"rspamd"
"snmp"
"surfboard"
Expand Down
19 changes: 19 additions & 0 deletions 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}
'';
};
};
}
14 changes: 14 additions & 0 deletions nixos/tests/prometheus-exporters.nix
Expand Up @@ -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;
Expand Down

0 comments on commit 344e64a

Please sign in to comment.