From b885a3b6e95a9b68db0bba1c2ffa00fdeaab4019 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 2 Dec 2021 14:36:56 +0200 Subject: [PATCH] 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 --- docs/CHANGELOG.md | 1 + lib/httpserver/httpserver.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8564be0274..d7eacd4d3e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,6 +18,7 @@ sort: 15 * FEATURE: vmalert: make `-notifier.url` command-line flag optional. This flag can be omitted if `vmalert` is used solely for recording rules and doesn't evaluate alerting rules. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1870). * FEATURE: [vmbackup](https://docs.victoriametrics.com/vmbackup.html), [vmrestore](https://docs.victoriametrics.com/vmrestore.html): export internal metrics at `http://vmbackup:8420/metrics` and `http://vmrestore:8421/metrics` for better visibility of the backup/restore process. * FEATURE: allow trailing whitespace after the timestamp when [parsing Graphite plaintext lines](https://docs.victoriametrics.com/#how-to-send-data-from-graphite-compatible-agents-such-as-statsd). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1865). +* FEATURE: expose `/-/healthy` and `/-/ready` endpoints as Prometheus does. This is needed for improving integration with third-party solutions, which rely on these endpoints. See [tis issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1833). * BUGFIX: vmagent: prevent from scraping duplicate targets if `-promscrape.dropOriginalLabels` command-line flag is set. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1830). Thanks to @guidao for the fix. * BUGFIX: vmstorage [enterprise](https://victoriametrics.com/enterprise.html): added missing `vm_tenant_used_tenant_bytes` metric, which shows the approximate per-tenant disk usage. See [these docs](https://docs.victoriametrics.com/PerTenantStatistic.html) and [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1605). diff --git a/lib/httpserver/httpserver.go b/lib/httpserver/httpserver.go index 1679576c4c..1e37a3ead1 100644 --- a/lib/httpserver/httpserver.go +++ b/lib/httpserver/httpserver.go @@ -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()