about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliButz <wbutz@cyberfnord.de>2019-08-11 13:33:42 +0200
committerWilliButz <wbutz@cyberfnord.de>2019-08-12 10:42:28 +0200
commit543f219b30c9bde1a9a7e258a18cd3205f1ee013 (patch)
tree7389f3fb5a3157fc91967806ffecdc0ceb2c6f7f
parenta0a0106f59c6ef120c04d9be30c4ae09f7eda620 (diff)
downloadnixlib-543f219b30c9bde1a9a7e258a18cd3205f1ee013.tar
nixlib-543f219b30c9bde1a9a7e258a18cd3205f1ee013.tar.gz
nixlib-543f219b30c9bde1a9a7e258a18cd3205f1ee013.tar.bz2
nixlib-543f219b30c9bde1a9a7e258a18cd3205f1ee013.tar.lz
nixlib-543f219b30c9bde1a9a7e258a18cd3205f1ee013.tar.xz
nixlib-543f219b30c9bde1a9a7e258a18cd3205f1ee013.tar.zst
nixlib-543f219b30c9bde1a9a7e258a18cd3205f1ee013.zip
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.
-rw-r--r--nixos/modules/services/monitoring/prometheus/default.nix26
1 files 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 <link xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alertmanager_config">the official documentation</link> for more information.
         '';
       };