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
This commit is contained in:
Gustavo Garcia 2025-05-22 11:37:29 +02:00 committed by GitHub
parent 8a71069517
commit de84ecefb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);