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

fix(promtail): Fix cri tags extra new lines. #7997

Merged
merged 2 commits into from
Dec 23, 2022

Conversation

kavirajk
Copy link
Contributor

@kavirajk kavirajk commented Dec 22, 2022

What this PR does / why we need it:
When re-creating single lines from multiple partial lines, \n should be avoided to join the partial lines.

Related: #6177 (comment)

Example
if Original log line is

{"a": "very long json field split in two lines"}

And got split into partial lines via CRI

2022-09-20T17:51:01.214529932Z stdout P {"a": "very long json field 
2022-09-20T17:51:01.214697597Z stdout F split in two lines"}

The result should be without \n when joining both of those lines.

Signed-off-by: Kaviraj [email protected]

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

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide
  • Tests updated
  • CHANGELOG.md updated

When re-creating single lines from multiple partial lines, `\n` should be avoided to join the partial lines.

Related: #6177 (comment)

Fixes: #7996

Signed-off-by: Kaviraj <[email protected]>
Signed-off-by: Kaviraj <[email protected]>
@kavirajk kavirajk marked this pull request as ready for review December 22, 2022 15:00
@kavirajk kavirajk requested a review from a team as a code owner December 22, 2022 15:00
@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%

Copy link
Contributor

@MasslessParticle MasslessParticle left a comment

Choose a reason for hiding this comment

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

This looks good. I'm concerned about the spacing, though.

@@ -107,50 +107,33 @@ func TestCRI_tags(t *testing.T) {
{
name: "tag P",
lines: []string{
"2019-05-07T18:57:50.904275087+00:00 stdout P partial line 1",
"2019-05-07T18:57:50.904275087+00:00 stdout P partial line 2",
"2019-05-07T18:57:50.904275087+00:00 stdout P partial line 1 ",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do partial lines come in with a space at the end or should we be joining with " "?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we have to handle the spaces here, cri will just split without any adding any extra characters. We should join as it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, it looks like cri-o splits lines wherever. Thanks!

Copy link
Contributor

@MasslessParticle MasslessParticle left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -107,50 +107,33 @@ func TestCRI_tags(t *testing.T) {
{
name: "tag P",
lines: []string{
"2019-05-07T18:57:50.904275087+00:00 stdout P partial line 1",
"2019-05-07T18:57:50.904275087+00:00 stdout P partial line 2",
"2019-05-07T18:57:50.904275087+00:00 stdout P partial line 1 ",
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, it looks like cri-o splits lines wherever. Thanks!

@kavirajk kavirajk merged commit d5b68c0 into main Dec 23, 2022
@kavirajk kavirajk deleted the kavirajk/fix-extra-newlines-cri-tags branch December 23, 2022 05:56
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 cri stage should not insert newlines while joining partial log lines
3 participants