-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Improve Prometheus metrics removal #3287
Merged
traefiker
merged 7 commits into
traefik:v1.6
from
m3co-code:improve-prometheus-metrics-removal
Jun 5, 2018
Merged
Improve Prometheus metrics removal #3287
traefiker
merged 7 commits into
traefik:v1.6
from
m3co-code:improve-prometheus-metrics-removal
Jun 5, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ldez
added
kind/enhancement
a new or improved feature.
status/2-needs-review
area/middleware/metrics
contributor/waiting-for-corrections
and removed
status/0-needs-triage
labels
May 8, 2018
m3co-code
force-pushed
the
improve-prometheus-metrics-removal
branch
from
May 8, 2018 13:01
461dbd8
to
5aad642
Compare
ldez
added
status/1-needs-design-review
and removed
contributor/waiting-for-corrections
status/2-needs-review
labels
May 8, 2018
m3co-code
force-pushed
the
improve-prometheus-metrics-removal
branch
from
May 8, 2018 15:46
5aad642
to
b77b8e3
Compare
This comment has been minimized.
This comment has been minimized.
m3co-code
force-pushed
the
improve-prometheus-metrics-removal
branch
2 times, most recently
from
May 8, 2018 16:00
48d5833
to
72aef4e
Compare
m3co-code
force-pushed
the
improve-prometheus-metrics-removal
branch
from
May 25, 2018 07:53
acce4d9
to
bc1c3c8
Compare
mmatur
approved these changes
May 30, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏 Nice job!!
mmatur
changed the title
improve Prometheus metrics removal
Improve Prometheus metrics removal
Jun 5, 2018
juliens
approved these changes
Jun 5, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ldez
approved these changes
Jun 5, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We need to build Traefik's dynamic configuration in test cases outside of the server package as well. Therefore, this commit moves them to the testhelpers package in order to make them reusable.
Formerly metric removal was done by tracking configuration generations. This was an easy first solution but is actually not really correct and for setups where Traefik does not receive a lot of configuration updates, old metrics can hang around for quite some time. The new approach is to keep track of Traefik's current configuration and to remove metrics that "belong" to an outdated configuration, once they were scraped. This way we can be sure that we don't keep old metrics too long and we can ensure that metrics for short-lived configuration still appear when the /metrics is scraped, as we only remove them after the scrape happened.
Given a metric is removed due to it belonging to an outdated part of the configuration, we also must delete the underlying Prometheus metric. Otherwise, given the formerly removed metric is tracked once more (with the same label pairs), it will start off from the value it had before the removal.
traefiker
force-pushed
the
improve-prometheus-metrics-removal
branch
from
June 5, 2018 10:14
1d118c7
to
d42fa38
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Improve Prometheus metrics removal.
Motivation
Formerly metric removal was done by tracking configuration generations. This was an easy first solution but is actually not correct and for setups where Traefik does not receive a lot of configuration updates, old metrics can hang around for quite some time.
The new approach is to keep track of Traefik's current configuration and to remove metrics that "belong" to an outdated configuration, once they were scraped. This way we can be sure that we don't keep old metrics too long and we can ensure that metrics for short-lived configuration still appear when the /metrics is scraped, as we only remove them after the scrape happened.
More