Skip to content

Commit

Permalink
[exporter/loki] Do not retry on 4xx status code (excluding 429) (#18083)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiardvanrij authored Jan 30, 2023
1 parent 5a0b7d0 commit 0922aac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .chloggen/loki-do-not-retry-on-permanent-error.yaml
Original file line number Diff line number Diff line change
@@ -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]
8 changes: 8 additions & 0 deletions exporter/lokiexporter/next_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 0922aac

Please sign in to comment.