From 7c0dd85a7cea242d5e2863b5529c6975090b5522 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 4 Dec 2019 19:15:49 +0200 Subject: [PATCH] lib/httpserver: add `/ping` handler for compatibility with Influx agents Certain Influx agents check for `/ping` endpoint before starting to send Influx line protocol data. See https://docs.influxdata.com/influxdb/v1.7/tools/api/#ping-http-endpoint --- lib/httpserver/httpserver.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/httpserver/httpserver.go b/lib/httpserver/httpserver.go index 0c2bec4a3..13fc64aa8 100644 --- a/lib/httpserver/httpserver.go +++ b/lib/httpserver/httpserver.go @@ -133,6 +133,15 @@ func handlerWrapper(w http.ResponseWriter, r *http.Request, rh RequestHandler) { w.Header().Set("Content-Type", "text/plain") w.Write([]byte("OK")) return + case "/ping": + // This is needed for compatibility with Influx agents. + // See https://docs.influxdata.com/influxdb/v1.7/tools/api/#ping-http-endpoint + status := http.StatusNoContent + if verbose := r.FormValue("verbose"); verbose == "true" { + status = http.StatusOK + } + w.WriteHeader(status) + return case "/metrics": startTime := time.Now() metricsRequests.Inc()