alertmanager: implement HA clustering support

This commit is contained in:
Robin Gloster 2020-04-13 18:39:51 +02:00
parent 326756bbeb
commit e484ca3d9b
No known key found for this signature in database
GPG Key ID: D5C458DF6DD97EDF

View File

@ -21,6 +21,8 @@ let
"--config.file /tmp/alert-manager-substituted.yaml"
"--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
"--log.level ${cfg.logLevel}"
"--storage.path /var/lib/alertmanager"
(toString (map (peer: "--cluster.peer ${peer}:9094") cfg.clusterPeers))
] ++ (optional (cfg.webExternalUrl != null)
"--web.external-url ${cfg.webExternalUrl}"
) ++ (optional (cfg.logFormat != null)
@ -120,6 +122,14 @@ in {
'';
};
clusterPeers = mkOption {
type = types.listOf types.str;
default = [];
description = ''
Initial peers for HA cluster.
'';
};
extraFlags = mkOption {
type = types.listOf types.str;
default = [];
@ -162,6 +172,7 @@ in {
'';
serviceConfig = {
Restart = "always";
StateDirectory = "alertmanager";
DynamicUser = true; # implies PrivateTmp
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
WorkingDirectory = "/tmp";