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

Bump loki.write code to latest client manager changes #4483

Merged
merged 16 commits into from
Jul 27, 2023

Conversation

thepalbi
Copy link
Contributor

@thepalbi thepalbi commented Jul 17, 2023

PR Description

This PR bumps the Promtail code used in the loki.write component to the latest changes (this commit that refactors all remote write client types into once client manager). This allows us to use the new client.Manager for orchestrating multiple remote-write clients. By doing this, for example, we can replace the inlined fanfout client implementation inside the component with the one implemented inside the client.Manager.

A follow up PR will expose river support for enabling the WAL within the manager, which is configured through this struct.

At the moment, this PR brings no new functionality, since the remote write clients are configured the same.

Which issue(s) this PR fixes

Notes to the Reviewer

  • Address changes that were done over the previously forklifted code

PR Checklist

  • CHANGELOG updated
  • Documentation added
  • Tests updated

@thepalbi thepalbi changed the title Bump Promtail code to latest client manager changes Bump loki.write code to latest client manager changes Jul 25, 2023
@thepalbi thepalbi marked this pull request as ready for review July 25, 2023 12:36
Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

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

LGTM, nothing much to add. (FWIW I only skimmed through the WAL code ported over).

I wanted to ask, how much of an effort do you feel this was? Any ideas to make it better in the future?

Comment on lines +8 to +14
ReadlineRate float64 `mapstructure:"readline_rate" yaml:"readline_rate" json:"readline_rate"`
ReadlineBurst int `mapstructure:"readline_burst" yaml:"readline_burst" json:"readline_burst"`
ReadlineRateEnabled bool `mapstructure:"readline_rate_enabled,omitempty" yaml:"readline_rate_enabled,omitempty" json:"readline_rate_enabled"`
ReadlineRateDrop bool `mapstructure:"readline_rate_drop,omitempty" yaml:"readline_rate_drop,omitempty" json:"readline_rate_drop"`
MaxStreams int `mapstructure:"max_streams" yaml:"max_streams" json:"max_streams"`
MaxLineSize flagext.ByteSize `mapstructure:"max_line_size" yaml:"max_line_size" json:"max_line_size"`
MaxLineSizeTruncate bool `mapstructure:"max_line_size_truncate" yaml:"max_line_size_truncate" json:"max_line_size_truncate"`
Copy link
Member

@tpaschalis tpaschalis Jul 27, 2023

Choose a reason for hiding this comment

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

nit: I know we probably copied these from loki, but could we remove the field tags here? Maybe also use units.Base2Bytes instead of flagext.ByteSize?

edit: maybe we can postpone this for later on, as we're tidying up all test files and structs, no need to do something right now.

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 can leave it for a follow up is that's ok. Creates this to track a couple

Comment on lines -96 to -98
m.streamLag = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "loki_write_stream_lag_seconds",
Help: "Difference between current time and last batch timestamp for successful sends",
Copy link
Member

Choose a reason for hiding this comment

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

Why did we end up removing the streamLag metric? Is it because the WAL implementation will not be synchronous and thus will have no meaning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the removal of that metrics was included in the forklifted changes from upstream (loki). See this commit

@thepalbi
Copy link
Contributor Author

thepalbi commented Jul 27, 2023

LGTM, nothing much to add. (FWIW I only skimmed through the WAL code ported over).

I wanted to ask, how much of an effort do you feel this was? Any ideas to make it better in the future?

@tpaschalis took me about a day of wrangling with the code (fixing types, some tests, race's that appeared here and not in loki (mainly becuase it's enabled).

After discussing with @cstyan , I'll change the approach for further work improving loki's remote write: The idea is to first do work in this repo, and then backport the changes (could be in batch) to Promtail. Since this is the primary logs agent we consume, it makes sense to make develop here first, since it will be more battle-tested.

I think that will solve mostly all pains since this is the place we needs changes ASAP, and we can figure out how to better manage the backport later.

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

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

Thanks!

component/common/loki/client/client.go Show resolved Hide resolved
@rfratto rfratto merged commit ac45b9a into main Jul 27, 2023
6 checks passed
@rfratto rfratto deleted the pablo/add-loki-write-wal branch July 27, 2023 13:05
dwalker-sabiogroup pushed a commit to dwalker-sabiogroup/agent that referenced this pull request Jul 28, 2023
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Feb 22, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants