From ce9145698297d5acbd23a97c7c8e017dcc247dfa Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 17 Feb 2022 12:45:20 +0200 Subject: [PATCH] app/vminsert: add `X-Influxdb-Version` response header for InfluxDB API requests This is needed for some clients, which expect this header. See https://github.com/ntop/ntopng/issues/5449#issuecomment-1005347597 --- app/vminsert/main.go | 8 ++++++++ docs/CHANGELOG.md | 1 + 2 files changed, 9 insertions(+) diff --git a/app/vminsert/main.go b/app/vminsert/main.go index 67f750384d..976f5ec8eb 100644 --- a/app/vminsert/main.go +++ b/app/vminsert/main.go @@ -237,6 +237,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { return true case "influx/write", "influx/api/v2/write": influxWriteRequests.Inc() + addInfluxResponseHeaders(w) if err := influx.InsertHandlerForHTTP(at, r); err != nil { influxWriteErrors.Inc() httpserver.Errorf(w, r, "%s", err) @@ -246,6 +247,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { return true case "influx/query": influxQueryRequests.Inc() + addInfluxResponseHeaders(w) influxutils.WriteDatabaseNames(w) return true case "datadog/api/v1/series": @@ -284,6 +286,12 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { } } +func addInfluxResponseHeaders(w http.ResponseWriter) { + // This is needed for some clients, which expect InfluxDB version header. + // See, for example, https://github.com/ntop/ntopng/issues/5449#issuecomment-1005347597 + w.Header().Set("X-Influxdb-Version", "1.8.0") +} + var ( requestDuration = metrics.NewHistogram(`vminsert_request_duration_seconds`) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 26931a7166..41af4f1e18 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,7 @@ The following tip changes can be tested by building VictoriaMetrics components f ## tip * FEATURE: add `-influxDBLabel` command-line flag for overriding `db` label name for the data [imported into VictoriaMetrics via InfluxDB line protocol](https://docs.victoriametrics.com/#how-to-send-data-from-influxdb-compatible-agents-such-as-telegraf). Thanks to @johnatannvmd for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2203). +* FEATURE: return `X-Influxdb-Version` HTTP header in responses to [InfluxDB write requests](https://docs.victoriametrics.com/#how-to-send-data-from-influxdb-compatible-agents-such-as-telegraf). This is needed for some InfluxDB clients. See, for example, [this comment](https://github.com/ntop/ntopng/issues/5449#issuecomment-1005347597). * BUGFIX: fix a bug, which could significantly slow down requests to `/api/v1/labels` and `/api/v1/label//values`. These APIs are used by Grafana for auto-completion of label names and label values. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2200). * BUGFIX: vmalert: add support for `$externalLabels` and `$externalURL` template vars in the same way as Prometheus does. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2193).