From 01f03f30db5755349b857b6939100bbb4c32303e Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Sun, 17 Nov 2019 14:35:33 +0900 Subject: nixos/prometheus: add checkConfig Workaround for https://github.com/prometheus/prometheus/issues/5222 --- .../services/monitoring/prometheus/default.nix | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'nixos/modules/services') diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index b67f697ca0d..6b1a4be44d1 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -9,12 +9,13 @@ let # a wrapper that verifies that the configuration is valid promtoolCheck = what: name: file: - pkgs.runCommand - "${name}-${replaceStrings [" "] [""] what}-checked" - { buildInputs = [ cfg.package ]; } '' - ln -s ${file} $out - promtool ${what} $out - ''; + if cfg.checkConfig then + pkgs.runCommand + "${name}-${replaceStrings [" "] [""] what}-checked" + { buildInputs = [ cfg.package ]; } '' + ln -s ${file} $out + promtool ${what} $out + '' else file; # Pretty-print JSON to a file writePrettyJSON = name: x: @@ -601,6 +602,20 @@ in { if Prometheus is served via a reverse proxy). ''; }; + + checkConfig = mkOption { + type = types.bool; + default = true; + description = '' + Check configuration with promtool + check. The call to promtool is + subject to sandboxing by Nix. When credentials are stored in + external files (password_file, + bearer_token_file, etc), they will not be + visible to promtool and it will report + errors, despite a correct configuration. + ''; + }; }; config = mkIf cfg.enable { -- cgit 1.4.1