about summary refs log tree commit diff
path: root/nixos/modules/services/monitoring
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2016-12-21 00:06:42 +0100
committerBjørn Forsman <bjorn.forsman@gmail.com>2016-12-21 00:32:24 +0100
commitcaa476b35760f095d3ed4faa910939a136d73356 (patch)
tree4b04753aaaa3f5ac493585d08da127d8e047cbe5 /nixos/modules/services/monitoring
parent3fb785b0ad6902d765601e489e5f695411d2752f (diff)
downloadnixlib-caa476b35760f095d3ed4faa910939a136d73356.tar
nixlib-caa476b35760f095d3ed4faa910939a136d73356.tar.gz
nixlib-caa476b35760f095d3ed4faa910939a136d73356.tar.bz2
nixlib-caa476b35760f095d3ed4faa910939a136d73356.tar.lz
nixlib-caa476b35760f095d3ed4faa910939a136d73356.tar.xz
nixlib-caa476b35760f095d3ed4faa910939a136d73356.tar.zst
nixlib-caa476b35760f095d3ed4faa910939a136d73356.zip
nixos/prometheus: add services.prometheus.configText option
The structured options are incomplete compared to upstream and I think
it will be a maintenance burden to try to keep up. Instead, provide an
option for the raw config file contents (prometheus.yml).
Diffstat (limited to 'nixos/modules/services/monitoring')
-rw-r--r--nixos/modules/services/monitoring/prometheus/default.nix19
1 files changed, 18 insertions, 1 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix
index 82b97bd92f87..d692dd5fc793 100644
--- a/nixos/modules/services/monitoring/prometheus/default.nix
+++ b/nixos/modules/services/monitoring/prometheus/default.nix
@@ -25,9 +25,16 @@ let
     scrape_configs = cfg.scrapeConfigs;
   };
 
+  generatedPrometheusYml = writePrettyJSON "prometheus.yml" promConfig;
+
+  prometheusYml =
+    if cfg.configText != null then
+      pkgs.writeText "prometheus.yml" cfg.configText
+    else generatedPrometheusYml;
+
   cmdlineArgs = cfg.extraFlags ++ [
     "-storage.local.path=${cfg.dataDir}/metrics"
-    "-config.file=${writePrettyJSON "prometheus.yml" promConfig}"
+    "-config.file=${prometheusYml}"
     "-web.listen-address=${cfg.listenAddress}"
     "-alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}"
     "-alertmanager.timeout=${toString cfg.alertmanagerTimeout}s"
@@ -359,6 +366,16 @@ in {
         '';
       };
 
+      configText = mkOption {
+        type = types.nullOr types.lines;
+        default = null;
+        description = ''
+          If non-null, this option defines the text that is written to
+          prometheus.yml. If null, the contents of prometheus.yml is generated
+          from the structured config options.
+        '';
+      };
+
       globalConfig = mkOption {
         type = promTypes.globalConfig;
         default = {};