From e3a0c808cff4de07c2f5749798daf56b932a6c37 Mon Sep 17 00:00:00 2001 From: Ruben Maher Date: Fri, 17 Aug 2018 14:16:23 +0930 Subject: [PATCH] modules/alertmanager: add clusterAdvertiseAddress option Alertmanager fails to start when the memberlist library cannot find any private IP addresses on the system. This is a safeguard to avoid exposing cluster ports over the internet unintentionally. The workaround is to pass the --cluster.advertise-address argument to AlertManager. See also: https://github.com/prometheus/alertmanager/pull/1437 https://github.com/prometheus/alertmanager/issues/1434 --- .../services/monitoring/prometheus/alertmanager.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/services/monitoring/prometheus/alertmanager.nix b/nixos/modules/services/monitoring/prometheus/alertmanager.nix index 8a47c9f1e7d89c..24c564d9adaef6 100644 --- a/nixos/modules/services/monitoring/prometheus/alertmanager.nix +++ b/nixos/modules/services/monitoring/prometheus/alertmanager.nix @@ -30,6 +30,17 @@ in { ''; }; + clusterAdvertiseAddress = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + If Alertmanager cannot find any private IP address on the host + machine, will fail to start unless an explicit advertise address is + provided. In that case, you can use the machine's public IP address + here. + ''; + }; + configuration = mkOption { type = types.attrs; default = {}; @@ -115,6 +126,7 @@ in { --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ --log.level ${cfg.logLevel} \ ${optionalString (cfg.webExternalUrl != null) ''--web.external-url ${cfg.webExternalUrl} \''} + ${optionalString (cfg.clusterAdvertiseAddress != null) ''--cluster.advertise-address ${cfg.clusterAdvertiseAddress} \''} ${optionalString (cfg.logFormat != null) "--log.format ${cfg.logFormat}"} '';