-
Notifications
You must be signed in to change notification settings - Fork 834
Support UTF-8 name #7056
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
Support UTF-8 name #7056
Conversation
7339ddb to
055e6ee
Compare
| require.Equal(t, 200, res.StatusCode) | ||
| require.Equal(t, model.ValVector, queryResult.Type()) | ||
| vec := queryResult.(model.Vector) | ||
| require.Equal(t, 1, len(vec)) |
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.
We should try to cover label names and label values API as well. But we can do it in next PR
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.
Should we remove https://github.com/cortexproject/cortex/blob/master/pkg/cortex/configinit/init.go as we start accepting UTF-8?
I've noticed the labelValues api with UTF-8 label name fails since we currently set the legacy scheme as default.
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.
We should. I think we might be missing some test cases so we didn't find this in previous PR. Any components that do label/metric validation needs to accept the validation scheme otherwise you modify the global validation scheme variable
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.
I removed it and added label names/values e2e test case.
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.
I think we are missing more test cases like alertmanager and even ruler configurations with UTF 8 labels.
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.
I added commits, testing the UTF-8 labels for Ruler and Alertmanager in the e2e test
21d3334 to
3a1c61e
Compare
integration/ruler_test.go
Outdated
| rulerFlags := mergeFlags( | ||
| BlocksStorageFlags(), | ||
| RulerFlags(), | ||
| ) |
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.
Same for this test case.
integration/alertmanager_test.go
Outdated
|
|
||
| silenceId, err := c.CreateSilence(ctx, types.Silence{ | ||
| Matchers: amlabels.Matchers{ | ||
| {Name: "silences.name.🙂", Value: "silences.value.🙂"}, |
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.
How did this test even succeed. We don't even add config to enable UTF 8 labels. Does it mean that AM support UTF 8 labels by default? but I think this is wrong and a behavior change after we remove /pkg/cortex/configinit/init.go. The UTF 8 validation should be properly controlled by the new runtime config.
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.
I think Alertmanager is able to control which validation mode to use via InitFromFlags. https://github.com/prometheus/alertmanager/blob/main/matcher/compat/parse.go#L59C6-L59C19.
However, this is not per tenant and global. That's why I was asking if per tenant metric name validation scheme really works or not. Seems we need some code changes to make that configuration not global in alertmanager.
Also you may add more utf-8 configs to route's matchers? Adding it to group_by alone Idk if it is sufficient.
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.
The Alertmanager Cortex uses this code, so the test succeeds since the default value of the scheme is UTF-8.
// isValidClassicLabelName returns true if the string is a valid classic label name.
func isValidClassicLabelName(_ *slog.Logger) func(model.LabelName) bool {
return func(name model.LabelName) bool {
return name.IsValid()
}
}
The upstream Alertmanager code is
func isValidClassicLabelName(_ *slog.Logger) func(model.LabelName) bool {
return func(name model.LabelName) bool {
return model.LegacyValidation.IsValidLabelName(string(name))
}
}
So, we need to expose another UTF-8 config for the Alertmanager.
That's why I was asking if per per-tenant metric name validation scheme really works or not.
It seems we should apply a per-tenant scheme for external label validation in the Ruler and Distributor, but the configuration for the Alertmanager should be applied globally. WDYT?
76b0dbb to
5e6abe6
Compare
5e6abe6 to
8bd64bb
Compare
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
69a8130 to
0f8f7fa
Compare
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.
Thanks!
Add a
-name-validation-schemeflag for supporting UTF-8 on CortexWe offer two encoding ways,
legacyorutf8.The
utf8mode enables UTF-8 encoding for validating label names and metric names.Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]