From 40c84a982f1a7ae7339a871c1dc6fd1590b4e2e5 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 8 Feb 2024 18:10:05 +0100 Subject: [PATCH] metrics: add option `metrics.addr` for ipv6 support `prometheus_client` supports IPv6 addresses for a while now[1]. This isn't used here however because the default 0.0.0.0 is used. Added an option `metrics.addr` that makes this configurable. [1] https://github.com/prometheus/client_python/commit/39d2360322262947adae1908d0972fba12ff8ed1 --- mautrix/util/program.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mautrix/util/program.py b/mautrix/util/program.py index 2fb6b141..00953fd5 100644 --- a/mautrix/util/program.py +++ b/mautrix/util/program.py @@ -188,6 +188,7 @@ def start_prometheus(self) -> None: try: enabled = self.config["metrics.enabled"] listen_port = self.config["metrics.listen_port"] + addr = self.config.get("metrics.addr", "0.0.0.0") except KeyError: return if not enabled: @@ -197,7 +198,7 @@ def start_prometheus(self) -> None: "Metrics are enabled in config, but prometheus_client is not installed" ) return - prometheus.start_http_server(listen_port) + prometheus.start_http_server(listen_port, addr=addr) def _run(self) -> None: signal.signal(signal.SIGINT, signal.default_int_handler)