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}"; }; }; };