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
This commit is contained in:
Aliaksandr Valialkin 2019-12-04 19:15:49 +02:00
parent 877b83ce97
commit 7c0dd85a7c

View file

@ -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()