From dec51b5ad978efef49294acd88abe14dd0696b71 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet Date: Fri, 9 Sep 2022 16:08:46 +0200 Subject: [PATCH] /-/{healthy,ready}/ respond to HEAD (#3039) Some frameworks issue HEAD requests to determine health. This is meant to be the alertmanager equivalent of prometheus/prometheus#11160 Signed-off-by: Nicolas Dumazet Signed-off-by: Nicolas Dumazet --- docs/management_api.md | 2 ++ ui/web.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/docs/management_api.md b/docs/management_api.md index a7b3ac5a..5e0c7582 100644 --- a/docs/management_api.md +++ b/docs/management_api.md @@ -12,6 +12,7 @@ Alertmanager provides a set of management API to ease automation and integration ``` GET /-/healthy +HEAD /-/healthy ``` This endpoint always returns 200 and should be used to check Alertmanager health. @@ -21,6 +22,7 @@ This endpoint always returns 200 and should be used to check Alertmanager health ``` GET /-/ready +HEAD /-/ready ``` This endpoint returns 200 when Alertmanager is ready to serve traffic (i.e. respond to queries). diff --git a/ui/web.go b/ui/web.go index fa1460d4..4d41a307 100644 --- a/ui/web.go +++ b/ui/web.go @@ -76,10 +76,16 @@ func Register(r *route.Router, reloadCh chan<- chan error, logger log.Logger) { w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "OK") })) + r.Head("/-/healthy", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + })) r.Get("/-/ready", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "OK") })) + r.Head("/-/ready", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + })) r.Get("/debug/*subpath", http.DefaultServeMux.ServeHTTP) r.Post("/debug/*subpath", http.DefaultServeMux.ServeHTTP)