From 2f75ae7e6256707cc0558e85524b0a2487c10ba6 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Thu, 25 Jan 2024 20:21:50 +0100 Subject: [PATCH] feat(matrix-synapse): enable metrics Following: https://github.com/matrix-org/synapse/blob/develop/docs/metrics-howto.md --- hosts/flora-6/apps/prometheus.nix | 19 ++++++++++-- hosts/nachtigall/apps/matrix/synapse.nix | 30 +++++++++++++++++++ hosts/nachtigall/apps/nginx-matrix.nix | 4 --- .../apps/nginx-prometheus-exporters.nix | 3 ++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/hosts/flora-6/apps/prometheus.nix b/hosts/flora-6/apps/prometheus.nix index 686045a8..11bc0bf0 100644 --- a/hosts/flora-6/apps/prometheus.nix +++ b/hosts/flora-6/apps/prometheus.nix @@ -26,7 +26,7 @@ }; scrapeConfigs = [ { - job_name = "http-targets"; + job_name = "node-exporter-http"; static_configs = [{ targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; labels = { @@ -35,7 +35,7 @@ }]; } { - job_name = "https-targets"; + job_name = "node-exporter-https"; scheme = "https"; metrics_path = "/metrics"; basic_auth = { @@ -49,6 +49,21 @@ }; }]; } + { + job_name = "matrix-synapse"; + scheme = "https"; + metrics_path = "/_synapse/metrics"; + basic_auth = { + username = "hakkonaut"; + password_file = "${config.age.secrets.nachtigall-metrics-prometheus-basic-auth-password.path}"; + }; + static_configs = [{ + targets = [ "nachtigall.pub.solar" ]; + labels = { + instance = "nachtigall"; + }; + }]; + } ]; }; } diff --git a/hosts/nachtigall/apps/matrix/synapse.nix b/hosts/nachtigall/apps/matrix/synapse.nix index e35c914f..240897a8 100644 --- a/hosts/nachtigall/apps/matrix/synapse.nix +++ b/hosts/nachtigall/apps/matrix/synapse.nix @@ -38,6 +38,32 @@ in allow_unsafe_locale = false; txn_limit = 0; }; + listeners = [ + { + bind_addresses = [ + "127.0.0.1" + ]; + port = 8008; + resources = [ + { + compress = true; + names = [ + "client" + ]; + } + { + compress = false; + names = [ + "federation" + "metrics" + ]; + } + ]; + tls = false; + type = "http"; + x_forwarded = true; + } + ]; account_threepid_delegates.msisdn = ""; alias_creation_rules = [{ @@ -68,6 +94,7 @@ in encryption_enabled_by_default_for_room_type = "off"; event_cache_size = "100K"; federation_rr_transactions_per_room_per_second = 50; + federation_client_minimum_tls_version = "1.2"; forget_rooms_on_leave = true; include_profile_data_on_invite = true; instance_map = { }; @@ -162,6 +189,7 @@ in stream_writers = { }; trusted_key_servers = [{ server_name = "matrix.org"; }]; + suppress_key_server_warning = true; turn_allow_guests = false; turn_uris = [ @@ -213,6 +241,8 @@ in ]; }; + withJemalloc = true; + extraConfigFiles = [ "/run/agenix/matrix-synapse-secret-config.yaml" diff --git a/hosts/nachtigall/apps/nginx-matrix.nix b/hosts/nachtigall/apps/nginx-matrix.nix index c9431466..a65a3dce 100644 --- a/hosts/nachtigall/apps/nginx-matrix.nix +++ b/hosts/nachtigall/apps/nginx-matrix.nix @@ -88,10 +88,6 @@ in gzip_types text/plain application/json; ''; locations = { - # TODO: Configure metrics - # "/metrics" = { - # }; - # For telegram "/c3c3f34b-29fb-5feb-86e5-98c75ec8214b" = { proxyPass = "http://127.0.0.1:8009"; diff --git a/hosts/nachtigall/apps/nginx-prometheus-exporters.nix b/hosts/nachtigall/apps/nginx-prometheus-exporters.nix index f46e6515..358f9fea 100644 --- a/hosts/nachtigall/apps/nginx-prometheus-exporters.nix +++ b/hosts/nachtigall/apps/nginx-prometheus-exporters.nix @@ -14,6 +14,9 @@ locations."/metrics" = { proxyPass = "http://127.0.0.1:${toString(config.services.prometheus.exporters.node.port)}"; }; + locations."/_synapse/metrics" = { + proxyPass = "http://127.0.0.1:${toString (builtins.map (listener: listener.port) config.services.matrix-synapse.settings.listeners)}"; + }; }; }; }