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

promtail: Add max-line-size limit to drop on client side #8153

Merged
merged 7 commits into from
Jan 16, 2023

Conversation

kavirajk
Copy link
Contributor

@kavirajk kavirajk commented Jan 16, 2023

What this PR does / why we need it:
promtail: Add max-line-size limit to drop on client side

Currently the workaround is to depend only on the loki server side limits.

This PR adds support in promtail to drop "too big" log lines. It also keep track of dropped lines in promtail_dropped_entries metric with reason max_line_size_limited.

Which issue(s) this PR fixes:
Fixes #8143

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated

Currently the workaround is to depend only on the loki server side limits.

This PR adds support in promtail to drop "too big" log lines. It also keep track of dropped lines in `promtail_dropped_entries` metrics
with reason `max_line_size_limited`.

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
@kavirajk kavirajk changed the title promtail: Add max-line-size limit to drop on client side promtail: Add max-line-size limit to drop on client side Jan 16, 2023
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
@kavirajk kavirajk force-pushed the kavirajk/add-max-size-limit-promtail branch from 5410119 to 5850cbd Compare January 16, 2023 08:40
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
@kavirajk kavirajk marked this pull request as ready for review January 16, 2023 08:55
@kavirajk kavirajk requested a review from a team as a code owner January 16, 2023 08:55
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

clients/pkg/promtail/client/client.go Outdated Show resolved Hide resolved
clients/pkg/promtail/client/client.go Outdated Show resolved Hide resolved
Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
…fana/loki into kavirajk/add-max-size-limit-promtail
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@kavirajk kavirajk requested a review from chaudum January 16, 2023 10:44
Copy link
Contributor

@chaudum chaudum left a comment

Choose a reason for hiding this comment

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

Otherwise ok. Approved to unblock.

CHANGELOG.md Outdated
@@ -26,7 +26,7 @@
* [8047](https://github.com/grafana/loki/pull/8047) **bboreham**: Dashboards: add k8s resource requests to CPU and memory panels.
* [8061](https://github.com/grafana/loki/pull/8061) **kavirajk**: Remove circle from Loki OSS
* [8131](https://github.com/grafana/loki/pull/8131) **jeschkies**: Compile Promtail ARM and ARM64 with journald support.

* [8153](https://github.com/grafana/loki/pull/8061) **kavirajk**: promtail: Add `max-line-size` limit to drop on client side
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move entry beneath # Promtail section.

@nicoche
Copy link
Contributor

nicoche commented Jan 16, 2023

Hey! Thanks for the fast reaction on my issue.

I think that the distributor's setting truncates the line at that size if it's greater, but does not drop it. Should we match this in promtail? In my case, I'd rather truncate it, but I see both choices are valid.

@kavirajk
Copy link
Contributor Author

I think that the distributor's setting truncates the line at that size if it's greater, but does not drop it. Should we match this in promtail? In my case, I'd rather truncate it, but I see both choices are valid.

The default behaviour is to drop it. It truncates only if distributor.max-line-size-truncate flag is set (default false)

Clarified that behaviour in the #8165.

I'm happy to add max-line-size-truncate flag to promtail as well to be consistent with distributor. But that needs introducing some additional new metrics into promtail (similar to mutated_samples_total in Loki). Will take in a different PR :)

kavirajk added a commit that referenced this pull request Jan 16, 2023
**What this PR does / why we need it**:
Add a clarrification of two flags `distributor.max-line-size` and
`distributor.max-line-size-truncate`. And clarity on [discarding the
logs](https://github.com/grafana/loki/blob/main/pkg/distributor/validator.go#L84-L92)
if later is disabled while still former is set to non-zero values.

Whereas if `distributor.max-line-size-truncate` is set, [log line is
only
truncated.](https://github.com/grafana/loki/blob/main/pkg/distributor/distributor.go#L517-L534)

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>

**Which issue(s) this PR fixes**:
Fixes #NA

**Special notes for your reviewer**:
Figured while working on PR #8153 

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@kavirajk kavirajk merged commit 2597429 into main Jan 16, 2023
@kavirajk kavirajk deleted the kavirajk/add-max-size-limit-promtail branch January 16, 2023 13:48
@nicoche
Copy link
Contributor

nicoche commented Jan 16, 2023

I think that the distributor's setting truncates the line at that size if it's greater, but does not drop it. Should we match this in promtail? In my case, I'd rather truncate it, but I see both choices are valid.

The default behaviour is to drop it. It truncates only if distributor.max-line-size-truncate flag is set (default false)

Clarified that behaviour in the #8165.

I'm happy to add max-line-size-truncate flag to promtail as well to be consistent with distributor. But that needs introducing some additional new metrics into promtail (similar to mutated_samples_total in Loki). Will take in a different PR :)

Great, thank you! Is there an issue to follow this? Also, lmk if you can't find time to do that, I could submit a PR.

jeschkies pushed a commit to jeschkies/loki that referenced this pull request Jan 18, 2023
…8165)

**What this PR does / why we need it**:
Add a clarrification of two flags `distributor.max-line-size` and
`distributor.max-line-size-truncate`. And clarity on [discarding the
logs](https://github.com/grafana/loki/blob/main/pkg/distributor/validator.go#L84-L92)
if later is disabled while still former is set to non-zero values.

Whereas if `distributor.max-line-size-truncate` is set, [log line is
only
truncated.](https://github.com/grafana/loki/blob/main/pkg/distributor/distributor.go#L517-L534)

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>

**Which issue(s) this PR fixes**:
Fixes #NA

**Special notes for your reviewer**:
Figured while working on PR grafana#8153 

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
jeschkies pushed a commit to jeschkies/loki that referenced this pull request Jan 18, 2023
kavirajk added a commit that referenced this pull request Jan 18, 2023
Follow up from #8153

Changes:
* Change type of the flag from `int` to `flagext.ByteSize` (to be consistent with similar flag in `distributor`)
* Add doc to promtail config page
* Fix changelog entries

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
kavirajk added a commit that referenced this pull request Jan 19, 2023
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>

**What this PR does / why we need it**:
Follow up from #8153

Changes:
* Change type of the flag from `int` to `flagext.ByteSize` (to be
consistent with similar flag in `distributor`)
* Add doc to promtail config page
* Fix changelog entries

**Which issue(s) this PR fixes**:
Fixes #NA

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added
- [x] `CHANGELOG.md` updated

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Promtail - limit log line length for static targets
4 participants