From 69b976607fe2f3d00fa978098fb22c025bcc598c Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sat, 27 Jan 2024 20:24:11 +0100 Subject: [PATCH] fix(matrix-synapse): make sure to find element in list of config.services.matrix-synapse.settings.listeners that sets type = "metrics" instead of just using the first element in the list --- hosts/nachtigall/apps/matrix/synapse.nix | 15 ++++++++++++++- .../apps/nginx-prometheus-exporters.nix | 13 ++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/hosts/nachtigall/apps/matrix/synapse.nix b/hosts/nachtigall/apps/matrix/synapse.nix index 240897a..93cff67 100644 --- a/hosts/nachtigall/apps/matrix/synapse.nix +++ b/hosts/nachtigall/apps/matrix/synapse.nix @@ -55,7 +55,6 @@ in compress = false; names = [ "federation" - "metrics" ]; } ]; @@ -63,6 +62,20 @@ in type = "http"; x_forwarded = true; } + { + bind_addresses = [ + "127.0.0.1" + ]; + port = 8012; + resources = [ + { + names = [ + "metrics" + ]; + } + ]; + type = "metrics"; + } ]; account_threepid_delegates.msisdn = ""; diff --git a/hosts/nachtigall/apps/nginx-prometheus-exporters.nix b/hosts/nachtigall/apps/nginx-prometheus-exporters.nix index e1f8e30..af5678c 100644 --- a/hosts/nachtigall/apps/nginx-prometheus-exporters.nix +++ b/hosts/nachtigall/apps/nginx-prometheus-exporters.nix @@ -1,7 +1,14 @@ { config, flake, lib, ... }: let - # Get port from first element in list of matrix-synapse listeners - synapsePort = "${toString (lib.findFirst (listener: listener.port != null) "" config.services.matrix-synapse.settings.listeners).port}"; + # Find element in list config.services.matrix-synapse.settings.listeners + # that sets type = "metrics" + listenerWithMetrics = lib.findFirst + (listener: + listener.type == "metrics") + (throw "Found no matrix-synapse.settings.listeners.*.type containing string metrics") + config.services.matrix-synapse.settings.listeners + ; + synapseMetricsPort = "${toString listenerWithMetrics.port}"; in { age.secrets.nachtigall-metrics-nginx-basic-auth = { @@ -18,7 +25,7 @@ in proxyPass = "http://127.0.0.1:${toString(config.services.prometheus.exporters.node.port)}"; }; locations."/_synapse/metrics" = { - proxyPass = "http://127.0.0.1:${synapsePort}"; + proxyPass = "http://127.0.0.1:${synapseMetricsPort}"; }; }; };