diff options
author | Thiago Kenji Okada <thiagokokada@gmail.com> | 2023-12-05 17:17:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 17:17:37 +0000 |
commit | bed09b735f7701a5b4f3e441654315e5fd7271b0 (patch) | |
tree | edbc81b8d19adedf31f89c6a6ceb104eadea076e /nixos | |
parent | 7cb7b7f98d81c2b9b907eacf5c29ec61078e80e4 (diff) | |
parent | 5c6c35d0f807fdb9562aaf06d0ce8f5bf6924fa0 (diff) | |
download | nixlib-bed09b735f7701a5b4f3e441654315e5fd7271b0.tar nixlib-bed09b735f7701a5b4f3e441654315e5fd7271b0.tar.gz nixlib-bed09b735f7701a5b4f3e441654315e5fd7271b0.tar.bz2 nixlib-bed09b735f7701a5b4f3e441654315e5fd7271b0.tar.lz nixlib-bed09b735f7701a5b4f3e441654315e5fd7271b0.tar.xz nixlib-bed09b735f7701a5b4f3e441654315e5fd7271b0.tar.zst nixlib-bed09b735f7701a5b4f3e441654315e5fd7271b0.zip |
Merge pull request #226923 from Drakonis/prometheus/agent-mode
nixos/prometheus: add `enableAgentMode` option
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/default.nix | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index 90ea56658b02..e78cb4d01dc5 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -41,12 +41,12 @@ let # This becomes the main config file for Prometheus promConfig = { global = filterValidPrometheus cfg.globalConfig; - rule_files = map (promtoolCheck "check rules" "rules") (cfg.ruleFiles ++ [ - (pkgs.writeText "prometheus.rules" (concatStringsSep "\n" cfg.rules)) - ]); scrape_configs = filterValidPrometheus cfg.scrapeConfigs; remote_write = filterValidPrometheus cfg.remoteWrite; remote_read = filterValidPrometheus cfg.remoteRead; + rule_files = optionals (!(cfg.enableAgentMode)) (map (promtoolCheck "check rules" "rules") (cfg.ruleFiles ++ [ + (pkgs.writeText "prometheus.rules" (concatStringsSep "\n" cfg.rules)) + ])); alerting = { inherit (cfg) alertmanagers; }; @@ -62,15 +62,20 @@ let promtoolCheck "check config ${lib.optionalString (cfg.checkConfig == "syntax-only") "--syntax-only"}" "prometheus.yml" yml; cmdlineArgs = cfg.extraFlags ++ [ - "--storage.tsdb.path=${workingDir}/data/" "--config.file=${ if cfg.enableReload then "/etc/prometheus/prometheus.yaml" else prometheusYml }" "--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}" + ] ++ ( + if (cfg.enableAgentMode) then [ + "--enable-feature=agent" + ] else [ + "--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity }" + "--storage.tsdb.path=${workingDir}/data/" + ]) + ++ optional (cfg.webExternalUrl != null) "--web.external-url=${cfg.webExternalUrl}" ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}" ++ optional (cfg.webConfigFile != null) "--web.config.file=${cfg.webConfigFile}"; @@ -1612,6 +1617,8 @@ in ''; }; + enableAgentMode = mkEnableOption (lib.mdDoc "agent mode"); + configText = mkOption { type = types.nullOr types.lines; default = null; |