summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorLassulus <github@lassul.us>2020-08-23 09:29:01 +0200
committerGitHub <noreply@github.com>2020-08-23 09:29:01 +0200
commitbfd706923e4d0781f4aad65beca9d5d7d167de6b (patch)
tree594bc03d788a9a1885614ea6f0e93ec3bbfe3b04 /nixos
parent2df0a3e45304648bcf74a7567289235ec2af3d86 (diff)
parente1d80de838d31bd1f05369120ecd7d4b191e9f9c (diff)
downloadnixpkgs-bfd706923e4d0781f4aad65beca9d5d7d167de6b.tar
nixpkgs-bfd706923e4d0781f4aad65beca9d5d7d167de6b.tar.gz
nixpkgs-bfd706923e4d0781f4aad65beca9d5d7d167de6b.tar.bz2
nixpkgs-bfd706923e4d0781f4aad65beca9d5d7d167de6b.tar.lz
nixpkgs-bfd706923e4d0781f4aad65beca9d5d7d167de6b.tar.xz
nixpkgs-bfd706923e4d0781f4aad65beca9d5d7d167de6b.tar.zst
nixpkgs-bfd706923e4d0781f4aad65beca9d5d7d167de6b.zip
Merge pull request #87700 from serokell/mkaito/upstream/prometheus-port
prometheus: Split options listenAddress and port
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/prometheus/default.nix27
1 files changed, 25 insertions, 2 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix
index 84a72afac2f..d7e06484b69 100644
--- a/nixos/modules/services/monitoring/prometheus/default.nix
+++ b/nixos/modules/services/monitoring/prometheus/default.nix
@@ -46,7 +46,7 @@ let
   cmdlineArgs = cfg.extraFlags ++ [
     "--storage.tsdb.path=${workingDir}/data/"
     "--config.file=${prometheusYml}"
-    "--web.listen-address=${cfg.listenAddress}"
+    "--web.listen-address=${cfg.listenAddress}:${builtins.toString cfg.port}"
     "--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}"
     "--alertmanager.timeout=${toString cfg.alertmanagerTimeout}s"
   ] ++
@@ -489,9 +489,17 @@ in {
       '';
     };
 
+    port = mkOption {
+      type = types.port;
+      default = 9090;
+      description = ''
+        Port to listen on.
+      '';
+    };
+
     listenAddress = mkOption {
       type = types.str;
-      default = "0.0.0.0:9090";
+      default = "0.0.0.0";
       description = ''
         Address to listen on for the web interface, API, and telemetry.
       '';
@@ -619,6 +627,21 @@ in {
   };
 
   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";