From 1c991a94d8a0795a8b71eb2f1b0fd0c018839204 Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 15 Oct 2021 12:47:40 +0200 Subject: [PATCH] metrics: add /health endpoint for healthchecks (#84) 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