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

Collapse multiline logs based on a start line. #3024

Merged
merged 15 commits into from
Dec 3, 2020

Conversation

jeschkies
Copy link
Contributor

@jeschkies jeschkies commented Dec 3, 2020

Summary:
This is a very simple approach based on #1380 to provide multiline
or block log entries in promtail.

A multiline stage is added to pipelines. This stages matches a start
line. Once a start line is matched all following lines are appended
to an entry and not passed on to downstream stages. Once a new start
line is matched the former block of multilines is sent.

If no new line arrives within max_wait_time the block is flushed to
the next stage and a new block is started.

If a block exceeds max_lines it is flushed as well.

Which issue(s) this PR fixes:
Resolves #74

Checklist

  • Documentation added
  • Tests updated

Summary:
This is a very simple approach based on grafana#1380 to provide multiline
or block log entries in promtail.

A `multiline` stage is added to pipelines. This stages matches a start
line. Once a start line is matched all following lines are appended
to an entry and not passed on to downstream stages. Once a new start
line is matched the former block of multilines is sent.

If now new line arrives withing `max_wait_time` the block is flushed to
the next stage and a new block is started.
@codecov-io
Copy link

codecov-io commented Dec 3, 2020

Codecov Report

Merging #3024 (f9ed133) into master (c4faa57) will decrease coverage by 0.03%.
The diff coverage is 73.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3024      +/-   ##
==========================================
- Coverage   62.63%   62.59%   -0.04%     
==========================================
  Files         185      186       +1     
  Lines       15731    15822      +91     
==========================================
+ Hits         9853     9904      +51     
- Misses       4956     4992      +36     
- Partials      922      926       +4     
Impacted Files Coverage Δ
pkg/logentry/stages/stage.go 46.47% <0.00%> (-2.78%) ⬇️
pkg/logentry/stages/multiline.go 77.01% <77.01%> (ø)
pkg/promtail/positions/positions.go 46.80% <0.00%> (-11.71%) ⬇️
pkg/querier/queryrange/limits.go 91.66% <0.00%> (-4.17%) ⬇️
pkg/promtail/targets/file/filetarget.go 64.33% <0.00%> (-2.10%) ⬇️
pkg/logql/evaluator.go 91.24% <0.00%> (-0.41%) ⬇️
pkg/ingester/checkpoint.go 68.28% <0.00%> (+0.88%) ⬆️

jeschkies and others added 2 commits December 3, 2020 15:51
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM Great work @jeschkies

I know some folks that will be happy !

There's one last comment before we merge, about logging.

EDIT: and the mess I made with the func :p

@cyriltovena cyriltovena merged commit afc1e53 into grafana:master Dec 3, 2020
@jeschkies jeschkies deleted the karsten/multiline-2 branch December 3, 2020 16:00
@yacut
Copy link

yacut commented Dec 3, 2020

Wow, great work @jeschkies 🥇

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

A bit late on my review, but LGTM.

The one area I think we're lacking to address is log files which have many different structures (where the firstline concept feels a bit lacking). Not something we need to solve now though.

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.

Feature: multi-line logs
5 participants