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] Refactor promtail client metrics so that we can't have duplicate metrics collected for the lag metric. #5521

Merged
merged 6 commits into from
Mar 15, 2022

Conversation

cstyan
Copy link
Contributor

@cstyan cstyan commented Mar 3, 2022

Still some things I need to fix, but some quick reivews/sanity checks would be good.

So, this should solve #5494

The cause of the issue is relatively simple, there was nothing in our code ensuring that for multiple promtail clients in the same binary that this metric would have a unique labelset per client. External labels are not applied to the metrics on /metrics. I've done a few things in this PR:

  1. refactored the metrics initialization to be done from main.go, and the metrics struct is passed in to client constructors from there
  2. added a name field to the client config, this will be added as a label to the stream_lag metric (which afaict is the only per-client metric at the moment, the others are for all clients of a type)
  3. move the stream lag labels config option from the client config to the overall clients config section, the reason being that you can't register the same metric name with two different label sets

Signed-off-by: Callum Styan callumstyan@gmail.com

collected for the lag metric.

Signed-off-by: Callum Styan <callumstyan@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
@cstyan cstyan marked this pull request as ready for review March 4, 2022 06:00
@cstyan cstyan requested a review from a team as a code owner March 4, 2022 06:00
@cstyan cstyan changed the title WIP: [promtail] Refactor promtail client metrics so that we can't have duplicate metrics collected for the lag metric. [promtail] Refactor promtail client metrics so that we can't have duplicate metrics collected for the lag metric. Mar 4, 2022
lblSet[HostLabel] = c.cfg.URL.Host
// also set client name since if we have multiple promtail clients configured we will run into a
// duplicate metric collected with same labels error when trying to hit the /metrics endpoint
lblSet[ClientLabel] = c.name
Copy link
Contributor

Choose a reason for hiding this comment

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

id or config id would have work better IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for the configuration field name?

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

Copy link
Contributor

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

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

LGTM

configs.

Signed-off-by: Callum Styan <callumstyan@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.

4 participants