model: fix EscapeLabelName to not preserve colon in label names#907
Open
ogulcanaydogan wants to merge 1 commit into
Open
model: fix EscapeLabelName to not preserve colon in label names#907ogulcanaydogan wants to merge 1 commit into
ogulcanaydogan wants to merge 1 commit into
Conversation
Colons are reserved for metric names only per the Prometheus data model. EscapeMetricFamily and metricNeedsEscaping were using IsValidLegacyMetricName and EscapeName for label name contexts, causing colons to be preserved when they should be escaped. Add isValidLegacyLabelRune, IsValidLegacyLabelName, and EscapeLabelName that exclude colons. Update EscapeMetricFamily and metricNeedsEscaping to use the label-specific functions for label name contexts. Builds on the approach discussed in prometheus#889. Fixes prometheus/prometheus#18380 Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
This file contains hidden or 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
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.
Colons are reserved for metric names only per the Prometheus data model.
EscapeMetricFamilyandmetricNeedsEscapingwere usingIsValidLegacyMetricNameandEscapeNamefor label name contexts, causing colons to be preserved when they should be escaped.Fixes prometheus/prometheus#18380
Changes
isValidLegacyLabelRune: same asisValidLegacyRunebut excludes:IsValidLegacyLabelName: uses the label-specific rune validatorEscapeLabelName: mirrorsEscapeNamebut applies label name rulesEscapeMetricFamilyto useIsValidLegacyLabelNameandEscapeLabelNamefor label namesmetricNeedsEscapingto useIsValidLegacyLabelNamefor label namesBehavior
app:instance-idapp:instance_idapp_instance_idhttp.status:sumhttp_status:sumhttp_status_sumapp:instance-idU__app:instance_2d_idU__app_3a_instance_2d_idrequests:total(metric name)requests:totalrequests:total(unchanged)Metric names with colons continue to work correctly. Only label name escaping is affected.
Builds on the approach discussed in #889.