summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2022-12-15 23:18:55 +0100
committerGitHub <noreply@github.com>2022-12-15 23:18:55 +0100
commit78d53eadca3dbe330b1fe2c9bc99fc67ab102f72 (patch)
tree19f3b8e8cd18b152144625c0048e72b6bbbbfb77 /nixos/modules/services
parentf9b2c36a7fecf2aec209e0ac755d5338a89c1fcd (diff)
parent6e530b9edaca212cca79f1e389f2c365886acbff (diff)
downloadnixpkgs-78d53eadca3dbe330b1fe2c9bc99fc67ab102f72.tar
nixpkgs-78d53eadca3dbe330b1fe2c9bc99fc67ab102f72.tar.gz
nixpkgs-78d53eadca3dbe330b1fe2c9bc99fc67ab102f72.tar.bz2
nixpkgs-78d53eadca3dbe330b1fe2c9bc99fc67ab102f72.tar.lz
nixpkgs-78d53eadca3dbe330b1fe2c9bc99fc67ab102f72.tar.xz
nixpkgs-78d53eadca3dbe330b1fe2c9bc99fc67ab102f72.tar.zst
nixpkgs-78d53eadca3dbe330b1fe2c9bc99fc67ab102f72.zip
Merge pull request #201985 from Shawn8901/prometheus_web_config
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/monitoring/prometheus/default.nix18
1 files changed, 13 insertions, 5 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix
index f6bae8f9e96..f516b75ab10 100644
--- a/nixos/modules/services/monitoring/prometheus/default.nix
+++ b/nixos/modules/services/monitoring/prometheus/default.nix
@@ -3,7 +3,7 @@
 with lib;
 
 let
-  json = pkgs.formats.json { };
+  yaml = pkgs.formats.yaml { };
   cfg = config.services.prometheus;
   checkConfigEnabled =
     (lib.isBool cfg.checkConfig && cfg.checkConfig)
@@ -11,8 +11,6 @@ let
 
   workingDir = "/var/lib/" + cfg.stateDir;
 
-  prometheusYmlOut = "${workingDir}/prometheus-substituted.yaml";
-
   triggerReload = pkgs.writeShellScriptBin "trigger-reload-prometheus" ''
     PATH="${makeBinPath (with pkgs; [ systemd ])}"
     if systemctl -q is-active prometheus.service; then
@@ -38,7 +36,7 @@ let
         promtool ${what} $out
       '' else file;
 
-  generatedPrometheusYml = json.generate "prometheus.yml" promConfig;
+  generatedPrometheusYml = yaml.generate "prometheus.yml" promConfig;
 
   # This becomes the main config file for Prometheus
   promConfig = {
@@ -73,7 +71,8 @@ let
     "--web.listen-address=${cfg.listenAddress}:${builtins.toString cfg.port}"
     "--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}"
   ] ++ optional (cfg.webExternalUrl != null) "--web.external-url=${cfg.webExternalUrl}"
-    ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}";
+    ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}"
+    ++ optional (cfg.webConfigFile != null) "--web.config.file=${cfg.webConfigFile}";
 
   filterValidPrometheus = filterAttrsListRecursive (n: v: !(n == "_module" || v == null));
   filterAttrsListRecursive = pred: x:
@@ -1719,6 +1718,15 @@ in
       '';
     };
 
+    webConfigFile = mkOption {
+      type = types.nullOr types.path;
+      default = null;
+      description = lib.mdDoc ''
+        Specifies which file should be used as web.config.file and be passed on startup.
+        See https://prometheus.io/docs/prometheus/latest/configuration/https/ for valid options.
+      '';
+    };
+
     checkConfig = mkOption {
       type = with types; either bool (enum [ "syntax-only" ]);
       default = true;