summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2016-12-22 23:18:39 +0100
committerBjørn Forsman <bjorn.forsman@gmail.com>2017-01-14 15:41:05 +0100
commitd2413943fa3a66c63df5a13822523067468c2f60 (patch)
tree2362b200ccf40e11f2648f54b6f0d99dcc620067 /nixos
parent7d75dd71dc2ec829bc16a5ea074df0afa4bffc02 (diff)
downloadnixpkgs-d2413943fa3a66c63df5a13822523067468c2f60.tar
nixpkgs-d2413943fa3a66c63df5a13822523067468c2f60.tar.gz
nixpkgs-d2413943fa3a66c63df5a13822523067468c2f60.tar.bz2
nixpkgs-d2413943fa3a66c63df5a13822523067468c2f60.tar.lz
nixpkgs-d2413943fa3a66c63df5a13822523067468c2f60.tar.xz
nixpkgs-d2413943fa3a66c63df5a13822523067468c2f60.tar.zst
nixpkgs-d2413943fa3a66c63df5a13822523067468c2f60.zip
nixos/prometheus: add configText option for alertmanager
The reason being less mental overhead when reading upstream
documentation. Examples can be pasted right into the configuration
instead of translating to Nix attrset first.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/alertmanager.nix17
1 files changed, 16 insertions, 1 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/alertmanager.nix b/nixos/modules/services/monitoring/prometheus/alertmanager.nix
index da2cd02eaa3..cf761edad92 100644
--- a/nixos/modules/services/monitoring/prometheus/alertmanager.nix
+++ b/nixos/modules/services/monitoring/prometheus/alertmanager.nix
@@ -5,6 +5,10 @@ with lib;
 let
   cfg = config.services.prometheus.alertmanager;
   mkConfigFile = pkgs.writeText "alertmanager.yml" (builtins.toJSON cfg.configuration);
+  alertmanagerYml =
+    if cfg.configText != null then
+      pkgs.writeText "alertmanager.yml" cfg.configText
+    else mkConfigFile;
 in {
   options = {
     services.prometheus.alertmanager = {
@@ -34,6 +38,17 @@ in {
         '';
       };
 
+      configText = mkOption {
+        type = types.nullOr types.lines;
+        default = null;
+        description = ''
+          Alertmanager configuration as YAML text. If non-null, this option
+          defines the text that is written to alertmanager.yml. If null, the
+          contents of alertmanager.yml is generated from the structured config
+          options.
+        '';
+      };
+
       logFormat = mkOption {
         type = types.nullOr types.str;
         default = null;
@@ -96,7 +111,7 @@ in {
       after    = [ "network.target" ];
       script = ''
         ${pkgs.prometheus-alertmanager.bin}/bin/alertmanager \
-        -config.file ${mkConfigFile} \
+        -config.file ${alertmanagerYml} \
         -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
         -log.level ${cfg.logLevel} \
         ${optionalString (cfg.webExternalUrl != null) ''-web.external-url ${cfg.webExternalUrl} \''}