From de84ecefb18b71676c6b0d821a50feda6eb974a4 Mon Sep 17 00:00:00 2001 From: Gustavo Garcia Date: Thu, 22 May 2025 11:37:29 +0200 Subject: [PATCH] Restore returning 200 OK on root prometheus path for health check (#1678) Restore the support to return a 200 OK in the root prometheus endpoint (/) as stated in the documentation. This feature was lost when removing libpromhttp Fixes #1672 --- src/apps/relay/prom_server.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/apps/relay/prom_server.c b/src/apps/relay/prom_server.c index 9630cbc..2fd2b8d 100644 --- a/src/apps/relay/prom_server.c +++ b/src/apps/relay/prom_server.c @@ -56,6 +56,11 @@ MHD_RESULT promhttp_handler(void *cls, struct MHD_Connection *connection, const body = prom_collector_registry_bridge(PROM_COLLECTOR_REGISTRY_DEFAULT); mode = MHD_RESPMEM_MUST_FREE; status = MHD_HTTP_OK; + } else if (strcmp(url, "/") == 0) { + // Return 200 OK for root path as a health check + body = "ok"; + mode = MHD_RESPMEM_PERSISTENT; + status = MHD_HTTP_OK; } struct MHD_Response *response = MHD_create_response_from_buffer(strlen(body), body, mode);