From c8af42d69962d9e6824d51050b141ac4cbd0e36e Mon Sep 17 00:00:00 2001 From: Wiard van Rij Date: Sat, 28 Jan 2023 14:29:19 +0100 Subject: [PATCH 1/2] Do not retry on 4xx status code (excluding 429) --- exporter/lokiexporter/next_exporter.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exporter/lokiexporter/next_exporter.go b/exporter/lokiexporter/next_exporter.go index 323165a0147c..ed55a88d52ea 100644 --- a/exporter/lokiexporter/next_exporter.go +++ b/exporter/lokiexporter/next_exporter.go @@ -109,6 +109,14 @@ func (l *nextLokiExporter) sendPushRequest(ctx context.Context, tenant string, r line = scanner.Text() } err = fmt.Errorf("HTTP %d %q: %s", resp.StatusCode, http.StatusText(resp.StatusCode), line) + + // Errors with 4xx status code (excluding 429) should not be retried + if resp.StatusCode >= http.StatusBadRequest && + resp.StatusCode < http.StatusInternalServerError && + resp.StatusCode != http.StatusTooManyRequests { + return consumererror.NewPermanent(err) + } + return consumererror.NewLogs(err, ld) } From 0c0120d3e65559fa25517290487416106e261db7 Mon Sep 17 00:00:00 2001 From: Wiard van Rij Date: Sat, 28 Jan 2023 14:40:51 +0100 Subject: [PATCH 2/2] add changelog --- .chloggen/loki-do-not-retry-on-permanent-error.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .chloggen/loki-do-not-retry-on-permanent-error.yaml diff --git a/.chloggen/loki-do-not-retry-on-permanent-error.yaml b/.chloggen/loki-do-not-retry-on-permanent-error.yaml new file mode 100644 index 000000000000..44bb4661131c --- /dev/null +++ b/.chloggen/loki-do-not-retry-on-permanent-error.yaml @@ -0,0 +1,11 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'bug_fix' + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: exporter/loki + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Do not retry on 4xx status code (excluding 429), as these are permanent errors" + +# One or more tracking issues related to the change +issues: [18059]