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 359c4d6109
commit 1244ad810d

View file

@ -163,6 +163,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()