From 342f84c5693bff17778f9c972bc584b4a53d854a Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 8 Nov 2024 22:00:56 +0100 Subject: [PATCH] app/vlinsert/loki: show the original request body on parse errors This should simplify debugging. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7490 --- app/vlinsert/loki/loki_json.go | 6 +++--- docs/VictoriaLogs/CHANGELOG.md | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/vlinsert/loki/loki_json.go b/app/vlinsert/loki/loki_json.go index 5b178ef40..768691c11 100644 --- a/app/vlinsert/loki/loki_json.go +++ b/app/vlinsert/loki/loki_json.go @@ -57,7 +57,7 @@ func handleJSON(r *http.Request, w http.ResponseWriter) { n, err := parseJSONRequest(data, lmp) lmp.MustClose() if err != nil { - httpserver.Errorf(w, r, "cannot parse Loki json request: %s", err) + httpserver.Errorf(w, r, "cannot parse Loki json request: %s; data=%s", err, data) return } @@ -85,7 +85,7 @@ func parseJSONRequest(data []byte, lmp insertutils.LogMessageProcessor) (int, er streamsV := v.Get("streams") if streamsV == nil { - return 0, fmt.Errorf("missing `streams` item in the parsed JSON: %q", v) + return 0, fmt.Errorf("missing `streams` item in the parsed JSON") } streams, err := streamsV.Array() if err != nil { @@ -125,7 +125,7 @@ func parseJSONRequest(data []byte, lmp insertutils.LogMessageProcessor) (int, er // populate messages from `values` array linesV := stream.Get("values") if linesV == nil { - return rowsIngested, fmt.Errorf("missing `values` item in the parsed JSON %q", stream) + return rowsIngested, fmt.Errorf("missing `values` item in the parsed `stream` object %q", stream) } lines, err := linesV.Array() if err != nil { diff --git a/docs/VictoriaLogs/CHANGELOG.md b/docs/VictoriaLogs/CHANGELOG.md index b2e09278a..9a181a8f6 100644 --- a/docs/VictoriaLogs/CHANGELOG.md +++ b/docs/VictoriaLogs/CHANGELOG.md @@ -23,6 +23,7 @@ according to [these docs](https://docs.victoriametrics.com/victorialogs/quicksta * FEATURE: [syslog data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/syslog/): allow adding arbitrary [log fields](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) via `[label1=value1 ... labelN=valueN]` syntax inside Syslog messages. For example, `<165>1 2024-06-03T17:42:00.000Z example.com appname 12345 ID47 [field1=value1 field2=value2] some message`. * FEATURE: [syslog data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/syslog/): allow dropping the specified [log fields](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) during data ingestion. See [these docs](https://docs.victoriametrics.com/victorialogs/data-ingestion/syslog/#dropping-fields). * FEATURE: [syslog data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/syslog/): allow adding the specified [log fields](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) during data ingestion. See [these docs](https://docs.victoriametrics.com/victorialogs/data-ingestion/syslog/#adding-extra-fields). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7354). +* FEATURE: [Loki data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/#loki-json-api): show the original request body on parse errors. This should simplify debugging. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7490). * BUGFIX: [HTTP querying APIs](https://docs.victoriametrics.com/victorialogs/querying/#http-api): properly take into account the `end` query arg when calculating time range for [`_time:duration` filter](https://docs.victoriametrics.com/victorialogs/logsql/#time-filter). Previously the `_time:duration` filter was treated as `_time:[now-duration, now)`, while it should be treated as `_time:[end-duration, end)`.