diff --git a/app/vmagent/main.go b/app/vmagent/main.go index c7b0e3b54..5d019d831 100644 --- a/app/vmagent/main.go +++ b/app/vmagent/main.go @@ -179,6 +179,11 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { } path := strings.Replace(r.URL.Path, "//", "/", -1) + if strings.HasPrefix(path, "datadog/") { + // Trim suffix from paths starting from /datadog/ in order to support legacy DataDog agent. + // See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2670 + path = strings.TrimSuffix(path, "/") + } switch path { case "/api/v1/write": prometheusWriteRequests.Inc() @@ -263,7 +268,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true - case "/datadog/intake/": + case "/datadog/intake": datadogIntakeRequests.Inc() w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{}`) @@ -361,6 +366,11 @@ func processMultitenantRequest(w http.ResponseWriter, r *http.Request, path stri httpserver.Errorf(w, r, "cannot obtain auth token: %s", err) return true } + if strings.HasPrefix(p.Suffix, "datadog/") { + // Trim suffix from paths starting from /datadog/ in order to support legacy DataDog agent. + // See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2670 + p.Suffix = strings.TrimSuffix(p.Suffix, "/") + } switch p.Suffix { case "prometheus/", "prometheus", "prometheus/api/v1/write": prometheusWriteRequests.Inc() @@ -444,7 +454,7 @@ func processMultitenantRequest(w http.ResponseWriter, r *http.Request, path stri w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true - case "datadog/intake/": + case "datadog/intake": datadogIntakeRequests.Inc() w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{}`) @@ -481,7 +491,7 @@ var ( datadogValidateRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/datadog/api/v1/validate", protocol="datadog"}`) datadogCheckRunRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/datadog/api/v1/check_run", protocol="datadog"}`) - datadogIntakeRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/datadog/intake/", protocol="datadog"}`) + datadogIntakeRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/datadog/intake", protocol="datadog"}`) promscrapeTargetsRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/targets"}`) promscrapeServiceDiscoveryRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/service-discovery"}`) diff --git a/app/vminsert/main.go b/app/vminsert/main.go index 68b3edb44..11d77f199 100644 --- a/app/vminsert/main.go +++ b/app/vminsert/main.go @@ -107,9 +107,6 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool { defer requestDuration.UpdateDuration(startTime) path := strings.Replace(r.URL.Path, "//", "/", -1) - if strings.HasPrefix(path, "/datadog") { - path = strings.TrimSuffix(path, "/") - } if strings.HasPrefix(path, "/static") { staticServer.ServeHTTP(w, r) return true @@ -119,6 +116,11 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool { staticServer.ServeHTTP(w, r) return true } + if strings.HasPrefix(path, "/datadog/") { + // Trim suffix from paths starting from /datadog/ in order to support legacy DataDog agent. + // See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2670 + path = strings.TrimSuffix(path, "/") + } switch path { case "/prometheus/api/v1/write", "/api/v1/write": prometheusWriteRequests.Inc() @@ -205,7 +207,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool { w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true - case "/datadog/intake/": + case "/datadog/intake": datadogIntakeRequests.Inc() w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{}`) @@ -316,7 +318,7 @@ var ( datadogValidateRequests = metrics.NewCounter(`vm_http_requests_total{path="/datadog/api/v1/validate", protocol="datadog"}`) datadogCheckRunRequests = metrics.NewCounter(`vm_http_requests_total{path="/datadog/api/v1/check_run", protocol="datadog"}`) - datadogIntakeRequests = metrics.NewCounter(`vm_http_requests_total{path="/datadog/intake/", protocol="datadog"}`) + datadogIntakeRequests = metrics.NewCounter(`vm_http_requests_total{path="/datadog/intake", protocol="datadog"}`) promscrapeTargetsRequests = metrics.NewCounter(`vm_http_requests_total{path="/targets"}`) promscrapeServiceDiscoveryRequests = metrics.NewCounter(`vm_http_requests_total{path="/service-discovery"}`) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e5664756e..d913bb164 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -28,6 +28,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): add `-promscrape.suppressScrapeErrorsDelay` command-line flag, which can be used for delaying and aggregating the logging of per-target scrape errors. This may reduce the amounts of logs when `vmagent` scrapes many unreliable targets. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2575). Thanks to @jelmd for [the initial implementation](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2576). * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): add `-promscrape.cluster.name` command-line flag, which allows proper data de-duplication when the same target is scraped from multiple [vmagent clusters](https://docs.victoriametrics.com/vmagent.html#scraping-big-number-of-targets). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2679). +* BUGFIX: support for data ingestion in [DataDog format](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#how-to-send-data-from-datadog-agent) from legacy clients / agents. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2670). Thanks to @elProxy for the fix. * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): properly apply `alert_relabel_configs` relabeling rules to `-notifier.config` according to [these docs](https://docs.victoriametrics.com/vmalert.html#notifier-configuration-file). Thanks to @spectvtor for [the bugfix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2633). * BUGFIX: deny [background merge](https://valyala.medium.com/how-victoriametrics-makes-instant-snapshots-for-multi-terabyte-time-series-data-e1f3fb0e0282) when the storage enters read-only mode, e.g. when free disk space becomes lower than `-storage.minFreeDiskSpaceBytes`. Background merge needs additional disk space, so it could result in `no space left on device` errors. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2603).