Skip to content

feat(loki.source.file): Add option to set max_line_size#6026

Open
kalleep wants to merge 9 commits intomainfrom
kalleep/fix-loki-source-file-max-line-size
Open

feat(loki.source.file): Add option to set max_line_size#6026
kalleep wants to merge 9 commits intomainfrom
kalleep/fix-loki-source-file-max-line-size

Conversation

@kalleep
Copy link
Copy Markdown
Contributor

@kalleep kalleep commented Apr 9, 2026

Brief description of Pull Request

Add config max_line_size to protect against reading to large lines. Currently it is possible to OOM alloy if you read a really big file without any newlines.

Pull Request Details

Issue(s) fixed by this Pull Request

Part of: #6014

Notes to the Reviewer

This pr includes some small cleanups.

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

onPositionsFileError: c.args.OnPositionsFileError,
legacyPositionUsed: c.args.LegacyPositionsFile != "",
})
tailer := newTailer(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removed the helper newSource since it's not needed any more

watcherConfig tail.WatcherConfig

running *atomic.Bool
opts tailerOptions
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified this alot. Instead of storing every property from options we just store options

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

💻 Deploy preview available (fix(loki.source.file): Add option to set max_line_size):

@kalleep
Copy link
Copy Markdown
Contributor Author

kalleep commented Apr 9, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2f62c6492

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kalleep
Copy link
Copy Markdown
Contributor Author

kalleep commented Apr 9, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbb91610c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kalleep kalleep changed the title fix(loki.source.file): Add option to set max_line_size feat(loki.source.file): Add option to set max_line_size Apr 9, 2026
@kalleep
Copy link
Copy Markdown
Contributor Author

kalleep commented Apr 9, 2026

@codex review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

💻 Deploy preview available (feat(loki.source.file): Add option to set max_line_size):

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39573b31db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kalleep kalleep marked this pull request as ready for review April 9, 2026 15:08
@kalleep kalleep requested review from a team and clayton-cornell as code owners April 9, 2026 15:08
func (a *Arguments) SetToDefault() {
a.FileWatch.SetToDefault()
a.FileMatch.SetToDefault()
a.MaxLineSize = 1 * units.MiB
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this was unlimited and by default loki will reject entries over 256KB.

But we should find a reasonable default here.

Copy link
Copy Markdown
Contributor

@clayton-cornell clayton-cornell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion. Everything else is OK for doc input.

@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Apr 13, 2026
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/docs Docs Squad label across all Grafana Labs repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants