From 543f219b30c9bde1a9a7e258a18cd3205f1ee013 Mon Sep 17 00:00:00 2001 From: WilliButz Date: Sun, 11 Aug 2019 13:33:42 +0200 Subject: [PATCH 1/2] nixos/prometheus: replace 'alertmanagerURL' options for prometheus2 Prometheus2 does no longer support the command-line flag to specify an alertmanager. Instead it now supports both service discovery and configuration of alertmanagers in the alerting config section. Simply mapping the previous option to an entry in the new alertmanagers section is not enough to allow for complete configurations of an alertmanager. Therefore the option alertmanagerURL is no longer used and instead a full alertmanager configuration is expected. --- .../monitoring/prometheus/default.nix | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index d8384e0d35b3..647d67533b89 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -79,12 +79,8 @@ let (pkgs.writeText "prometheus.rules" (concatStringsSep "\n" cfg2.rules)) ]); scrape_configs = filterValidPrometheus cfg2.scrapeConfigs; - alerting = optionalAttrs (cfg2.alertmanagerURL != []) { - alertmanagers = [{ - static_configs = [{ - targets = cfg2.alertmanagerURL; - }]; - }]; + alerting = { + inherit (cfg2) alertmanagers; }; }; @@ -738,11 +734,23 @@ in { ''; }; - alertmanagerURL = mkOption { - type = types.listOf types.str; + alertmanagers = mkOption { + type = types.listOf types.attrs; + example = literalExample '' + [ { + scheme = "https"; + path_prefix = "/alertmanager"; + static_configs = [ { + targets = [ + "prometheus.domain.tld" + ]; + } ]; + } ] + ''; default = []; description = '' - List of Alertmanager URLs to send notifications to. + A list of alertmanagers to send alerts to. + See the official documentation for more information. ''; }; From a8847c870aa0b5acdbc7593616858bfd1b825fbf Mon Sep 17 00:00:00 2001 From: WilliButz Date: Sun, 11 Aug 2019 13:39:27 +0200 Subject: [PATCH 2/2] nixos/rename: add prometheus2 change --- nixos/modules/rename.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 4ae642222740..c44332237fc2 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -51,6 +51,10 @@ with lib; (mkRemovedOptionModule [ "services" "misc" "nzbget" "openFirewall" ] "The port used by nzbget is managed through the web interface so you should adjust your firewall rules accordingly.") (mkRemovedOptionModule [ "services" "prometheus" "alertmanager" "user" ] "The alertmanager service is now using systemd's DynamicUser mechanism which obviates a user setting.") (mkRemovedOptionModule [ "services" "prometheus" "alertmanager" "group" ] "The alertmanager service is now using systemd's DynamicUser mechanism which obviates a group setting.") + (mkRemovedOptionModule [ "services" "prometheus2" "alertmanagerURL" ] '' + Due to incompatibility, the alertmanagerURL option has been removed, + please use 'services.prometheus2.alertmanagers' instead. + '') (mkRenamedOptionModule [ "services" "tor" "relay" "portSpec" ] [ "services" "tor" "relay" "port" ]) (mkRenamedOptionModule [ "services" "vmwareGuest" ] [ "virtualisation" "vmware" "guest" ]) (mkRenamedOptionModule [ "jobs" ] [ "systemd" "services" ])