From 42cf5430c9658e4671f72c6e1e8872aa59d765f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 15 Oct 2021 12:38:52 +0200 Subject: [PATCH] metrics: add /health endpoint for healthchecks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because calling `/metrics` for a Consul healhcheck is too heavy and far too verbose. Signed-off-by: Jakub SokoĊ‚owski --- waku/metrics/http.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/waku/metrics/http.go b/waku/metrics/http.go index 37b565ea..3393f0cf 100644 --- a/waku/metrics/http.go +++ b/waku/metrics/http.go @@ -40,6 +40,11 @@ func NewMetricsServer(address string, port int) *Server { mux := http.NewServeMux() mux.Handle("/metrics", pe) + // Healthcheck + mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, "OK") + }) + h := &ochttp.Handler{Handler: mux} // Register the views