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

log/loki: limit line size #2475

Merged
merged 3 commits into from
Jul 27, 2023
Merged

log/loki: limit line size #2475

merged 3 commits into from
Jul 27, 2023

Conversation

gsora
Copy link
Collaborator

@gsora gsora commented Jul 26, 2023

This PR limits the maximum size of each single log line to 4096 bytes in production workloads (i.e. for consumers of loki.New()).

This prevents pushing log lines too long for our instance of Loki, avoiding potential DoS.

As with batchMax, maxLogLineLen is not configurable except in tests.

category: misc
ticket: none

This commit limits the maximum size of each single log line to 4096 bytes in production workloads (i.e. for consumers of `loki.New()`).

This prevents pushing log lines too long for our instance of Loki, avoiding potential DoS.

As with batchMax, maxLogLineLen is not configurable except in tests.
@gsora gsora requested a review from corverroos July 26, 2023 10:19
@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Patch coverage: 83.33% and project coverage change: -0.05% ⚠️

Comparison is base (b86344c) 53.59% compared to head (cff365d) 53.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2475      +/-   ##
==========================================
- Coverage   53.59%   53.55%   -0.05%     
==========================================
  Files         198      198              
  Lines       26711    26715       +4     
==========================================
- Hits        14317    14307      -10     
- Misses      10608    10625      +17     
+ Partials     1786     1783       -3     
Files Changed Coverage Δ
app/log/loki/client.go 80.67% <83.33%> (+14.58%) ⬆️

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gsora gsora changed the title app/log/loki: limit line size log/loki: limit line size Jul 26, 2023
@@ -101,10 +104,15 @@ func (c *Client) Run() {
for {
select {
case line := <-c.input:
if len(line) > c.maxLogLineLen && c.maxLogLineLen != 0 {
continue // Silently drop log line longer than maxLogLineLen if set
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure about silent, what about using a log filter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm doing what batch does pretty much, we discussed this briefly on Slack and you suggested to just drop it.

What behavior would you like to see instead?

Copy link
Contributor

@corverroos corverroos Jul 26, 2023

Choose a reason for hiding this comment

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

well, log it using a log filter: log.Warn(ctx, "Dropping to large logging line", z.Str("prefix", line[:10]), dropFilter with dropFilter being dropFilter := log.Filter().

but sure, this is only loki client itself, which is not our primary logging framework, it is best effort, so yeah, maybe silent drop is fine.

@gsora gsora added the merge when ready Indicates bulldozer bot may merge when all checks pass label Jul 27, 2023
@obol-bulldozer obol-bulldozer bot merged commit 11166d9 into main Jul 27, 2023
13 of 14 checks passed
@obol-bulldozer obol-bulldozer bot deleted the gsora/loki-max-log-lines branch July 27, 2023 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants