Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/loki] Do not retry on 4xx status code (excluding 429) #18083

Merged
merged 2 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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