mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/{vminsert,vmagent}: add healthcheck for influx ingestion endpoints (#6749)
### Describe Your Changes
This is useful for clients which validate InfluxDB is available before
data ingestion can be started.
See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6653
### Checklist
The following checks are **mandatory**:
- [x] My change adheres [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/contributing/).
---------
Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
Signed-off-by: hagen1778 <roman@victoriametrics.com>
Co-authored-by: hagen1778 <roman@victoriametrics.com>
(cherry picked from commit 9877a5e7d5
)
Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
fdad3e94f5
commit
0b1def6e24
4 changed files with 28 additions and 2 deletions
|
@ -318,6 +318,10 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||||
influxQueryRequests.Inc()
|
influxQueryRequests.Inc()
|
||||||
influxutils.WriteDatabaseNames(w)
|
influxutils.WriteDatabaseNames(w)
|
||||||
return true
|
return true
|
||||||
|
case "/influx/health":
|
||||||
|
influxHealthRequests.Inc()
|
||||||
|
influxutils.WriteHealthCheckResponse(w)
|
||||||
|
return true
|
||||||
case "/opentelemetry/api/v1/push", "/opentelemetry/v1/metrics":
|
case "/opentelemetry/api/v1/push", "/opentelemetry/v1/metrics":
|
||||||
opentelemetryPushRequests.Inc()
|
opentelemetryPushRequests.Inc()
|
||||||
if err := opentelemetry.InsertHandler(nil, r); err != nil {
|
if err := opentelemetry.InsertHandler(nil, r); err != nil {
|
||||||
|
@ -564,6 +568,10 @@ func processMultitenantRequest(w http.ResponseWriter, r *http.Request, path stri
|
||||||
influxQueryRequests.Inc()
|
influxQueryRequests.Inc()
|
||||||
influxutils.WriteDatabaseNames(w)
|
influxutils.WriteDatabaseNames(w)
|
||||||
return true
|
return true
|
||||||
|
case "influx/health":
|
||||||
|
influxHealthRequests.Inc()
|
||||||
|
influxutils.WriteHealthCheckResponse(w)
|
||||||
|
return true
|
||||||
case "opentelemetry/api/v1/push", "opentelemetry/v1/metrics":
|
case "opentelemetry/api/v1/push", "opentelemetry/v1/metrics":
|
||||||
opentelemetryPushRequests.Inc()
|
opentelemetryPushRequests.Inc()
|
||||||
if err := opentelemetry.InsertHandler(at, r); err != nil {
|
if err := opentelemetry.InsertHandler(at, r); err != nil {
|
||||||
|
@ -674,7 +682,8 @@ var (
|
||||||
influxWriteRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/influx/write", protocol="influx"}`)
|
influxWriteRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/influx/write", protocol="influx"}`)
|
||||||
influxWriteErrors = metrics.NewCounter(`vmagent_http_request_errors_total{path="/influx/write", protocol="influx"}`)
|
influxWriteErrors = metrics.NewCounter(`vmagent_http_request_errors_total{path="/influx/write", protocol="influx"}`)
|
||||||
|
|
||||||
influxQueryRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/influx/query", protocol="influx"}`)
|
influxQueryRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/influx/query", protocol="influx"}`)
|
||||||
|
influxHealthRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/influx/health", protocol="influx"}`)
|
||||||
|
|
||||||
datadogv1WriteRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/datadog/api/v1/series", protocol="datadog"}`)
|
datadogv1WriteRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/datadog/api/v1/series", protocol="datadog"}`)
|
||||||
datadogv1WriteErrors = metrics.NewCounter(`vmagent_http_request_errors_total{path="/datadog/api/v1/series", protocol="datadog"}`)
|
datadogv1WriteErrors = metrics.NewCounter(`vmagent_http_request_errors_total{path="/datadog/api/v1/series", protocol="datadog"}`)
|
||||||
|
|
|
@ -299,6 +299,10 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||||
addInfluxResponseHeaders(w)
|
addInfluxResponseHeaders(w)
|
||||||
influxutils.WriteDatabaseNames(w)
|
influxutils.WriteDatabaseNames(w)
|
||||||
return true
|
return true
|
||||||
|
case "influx/health":
|
||||||
|
influxHealthRequests.Inc()
|
||||||
|
influxutils.WriteHealthCheckResponse(w)
|
||||||
|
return true
|
||||||
case "opentelemetry/api/v1/push", "opentelemetry/v1/metrics":
|
case "opentelemetry/api/v1/push", "opentelemetry/v1/metrics":
|
||||||
opentelemetryPushRequests.Inc()
|
opentelemetryPushRequests.Inc()
|
||||||
if err := opentelemetry.InsertHandler(at, r); err != nil {
|
if err := opentelemetry.InsertHandler(at, r); err != nil {
|
||||||
|
@ -423,7 +427,8 @@ var (
|
||||||
influxWriteRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/influx/write", protocol="influx"}`)
|
influxWriteRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/influx/write", protocol="influx"}`)
|
||||||
influxWriteErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/insert/{}/influx/write", protocol="influx"}`)
|
influxWriteErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/insert/{}/influx/write", protocol="influx"}`)
|
||||||
|
|
||||||
influxQueryRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/influx/query", protocol="influx"}`)
|
influxQueryRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/influx/query", protocol="influx"}`)
|
||||||
|
influxHealthRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/influx/health", protocol="influx"}`)
|
||||||
|
|
||||||
opentelemetryPushRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/opentelemetry/v1/metrics", protocol="opentelemetry"}`)
|
opentelemetryPushRequests = metrics.NewCounter(`vm_http_requests_total{path="/insert/{}/opentelemetry/v1/metrics", protocol="opentelemetry"}`)
|
||||||
opentelemetryPushErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/insert/{}/opentelemetry/v1/metrics", protocol="opentelemetry"}`)
|
opentelemetryPushErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/insert/{}/opentelemetry/v1/metrics", protocol="opentelemetry"}`)
|
||||||
|
|
|
@ -30,6 +30,7 @@ See also [LTS releases](https://docs.victoriametrics.com/lts-releases/).
|
||||||
|
|
||||||
## tip
|
## tip
|
||||||
|
|
||||||
|
* FEATURE: add `/influx/health` health-check handler for Influx endpoints. This is needed as some clients use the health endpoint to determine if the server is healthy and ready for data ingestion. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6653) for the details.
|
||||||
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl/): add `--vm-backoff-retries`, `--vm-backoff-factor`, `--vm-backoff-min-duration` and `--vm-native-backoff-retries`, `--vm-native-backoff-factor`, `--vm-native-backoff-min-duration` command-line flags. These flags allow to change backoff policy config for import requests to VictoriaMetrics. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6622).
|
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl/): add `--vm-backoff-retries`, `--vm-backoff-factor`, `--vm-backoff-min-duration` and `--vm-native-backoff-retries`, `--vm-native-backoff-factor`, `--vm-native-backoff-min-duration` command-line flags. These flags allow to change backoff policy config for import requests to VictoriaMetrics. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6622).
|
||||||
|
|
||||||
## [v1.102.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.102.1)
|
## [v1.102.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.102.1)
|
||||||
|
|
|
@ -27,3 +27,14 @@ func WriteDatabaseNames(w http.ResponseWriter) {
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, `{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[%s]}]}]}`, strings.Join(dbs, ","))
|
fmt.Fprintf(w, `{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[%s]}]}]}`, strings.Join(dbs, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteHealthCheckResponse writes response for influx ping to w.
|
||||||
|
func WriteHealthCheckResponse(w http.ResponseWriter) {
|
||||||
|
// Emulate fake response for influx ping.
|
||||||
|
// This is needed for some clients to detect whether InfluxDB is available.
|
||||||
|
// See:
|
||||||
|
// - https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6653
|
||||||
|
// - https://docs.influxdata.com/influxdb/v2/api/#operation/GetHealth
|
||||||
|
|
||||||
|
fmt.Fprintf(w, `{"name":"influxdb", "message":"ready for queries and writes", "status":"pass", "checks":[]}`)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue