lib/httpserver: expose /-/healthy and /-/ready endpoints as Prometheus does

This improves integration with third-party solutions, which rely on these endpoints.

See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1833
This commit is contained in:
Aliaksandr Valialkin
2021-12-02 14:36:56 +02:00
parent c540235470
commit b885a3b6e9
2 changed files with 11 additions and 0 deletions

View File

@@ -280,6 +280,16 @@ func handlerWrapper(s *server, w http.ResponseWriter, r *http.Request, rh Reques
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
flagutil.WriteFlags(w)
return
case "/-/healthy":
// This is needed for Prometheus compatibility
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1833
fmt.Fprintf(w, "VictoriaMetrics is Healthy.\n")
return
case "/-/ready":
// This is needed for Prometheus compatibility
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1833
fmt.Fprintf(w, "VictoriaMetrics is Ready.\n")
return
default:
if strings.HasPrefix(r.URL.Path, "/debug/pprof/") {
pprofRequests.Inc()