Merge pull request #87700 from serokell/mkaito/upstream/prometheus-port

prometheus: Split options listenAddress and port

Lassulus bfd70692 2df0a3e4

Changed files
+25 -2
nixos
modules
services
monitoring
prometheus
+25 -2
nixos/modules/services/monitoring/prometheus/default.nix
···
cmdlineArgs = cfg.extraFlags ++ [
"--storage.tsdb.path=${workingDir}/data/"
"--config.file=${prometheusYml}"
-
"--web.listen-address=${cfg.listenAddress}"
"--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}"
"--alertmanager.timeout=${toString cfg.alertmanagerTimeout}s"
] ++
···
'';
};
listenAddress = mkOption {
type = types.str;
-
default = "0.0.0.0:9090";
description = ''
Address to listen on for the web interface, API, and telemetry.
'';
···
};
config = mkIf cfg.enable {
users.groups.prometheus.gid = config.ids.gids.prometheus;
users.users.prometheus = {
description = "Prometheus daemon user";
···
cmdlineArgs = cfg.extraFlags ++ [
"--storage.tsdb.path=${workingDir}/data/"
"--config.file=${prometheusYml}"
+
"--web.listen-address=${cfg.listenAddress}:${builtins.toString cfg.port}"
"--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}"
"--alertmanager.timeout=${toString cfg.alertmanagerTimeout}s"
] ++
···
'';
};
+
port = mkOption {
+
type = types.port;
+
default = 9090;
+
description = ''
+
Port to listen on.
+
'';
+
};
+
listenAddress = mkOption {
type = types.str;
+
default = "0.0.0.0";
description = ''
Address to listen on for the web interface, API, and telemetry.
'';
···
};
config = mkIf cfg.enable {
+
assertions = [
+
( let
+
legacy = builtins.match "(.*):(.*)" cfg.listenAddress;
+
in {
+
assertion = legacy == null;
+
message = ''
+
Do not specify the port for Prometheus to listen on in the
+
listenAddress option; use the port option instead:
+
services.prometheus.listenAddress = ${builtins.elemAt legacy 0};
+
services.prometheus.port = ${builtins.elemAt legacy 1};
+
'';
+
}
+
)
+
];
+
users.groups.prometheus.gid = config.ids.gids.prometheus;
users.users.prometheus = {
description = "Prometheus daemon user";