fix(matrix-synapse): make sure to find element in
All checks were successful
Flake checks / Check (pull_request) Successful in 8m33s

list of config.services.matrix-synapse.settings.listeners that sets
type = "metrics" instead of just using the first element in the list
This commit is contained in:
teutat3s 2024-01-27 20:24:11 +01:00
parent 62429bca08
commit 69b976607f
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1
2 changed files with 24 additions and 4 deletions

View file

@ -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 = "";

View file

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