-
Notifications
You must be signed in to change notification settings - Fork 833
Add-changelog-for-utf8-support #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
base: master
Are you sure you want to change the base?
Changes from all commits
6998d49
055e6ee
46d3529
ebbc63b
3a1c61e
c665a41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,60 @@ func TestRulerSharding(t *testing.T) { | |
assert.ElementsMatch(t, expectedNames, actualNames) | ||
} | ||
|
||
func TestRulerAPIUTF8(t *testing.T) { | ||
s, err := e2e.NewScenario(networkName) | ||
require.NoError(t, err) | ||
defer s.Close() | ||
|
||
// Start dependencies. | ||
consul := e2edb.NewConsul() | ||
minio := e2edb.NewMinio(9000, bucketName, rulestoreBucketName) | ||
require.NoError(t, s.StartAndWaitReady(consul, minio)) | ||
|
||
rulerFlags := mergeFlags( | ||
BlocksStorageFlags(), | ||
RulerFlags(), | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for this test case. |
||
|
||
// Start ruler. | ||
ruler := e2ecortex.NewRuler("ruler", consul.NetworkHTTPEndpoint(), rulerFlags, "") | ||
require.NoError(t, s.StartAndWaitReady(ruler)) | ||
|
||
c, err := e2ecortex.NewClient("", "", "", ruler.HTTPEndpoint(), "user-1") | ||
require.NoError(t, err) | ||
|
||
groupLabels := map[string]string{ | ||
"group.label.🙂": "val.🙂", | ||
} | ||
ruleLabels := map[string]string{ | ||
"rule.label.🙂": "val.🙂", | ||
} | ||
|
||
interval, _ := model.ParseDuration("1s") | ||
|
||
ruleGroup := rulefmt.RuleGroup{ | ||
Name: "utf8Rule", | ||
Interval: interval, | ||
Rules: []rulefmt.Rule{{ | ||
Alert: "alert.rule", | ||
Expr: "up", | ||
Labels: ruleLabels, | ||
}, { | ||
Record: "record.rule", | ||
Expr: "up", | ||
Labels: ruleLabels, | ||
}}, | ||
Labels: groupLabels, | ||
} | ||
|
||
// Set rule group | ||
err = c.SetRuleGroup(ruleGroup, "namespace") | ||
require.NoError(t, err) | ||
|
||
require.NoError(t, ruler.WaitSumMetrics(e2e.Equals(1), "cortex_ruler_managers_total")) | ||
require.NoError(t, ruler.WaitSumMetrics(e2e.Equals(1), "cortex_ruler_rule_groups_in_store")) | ||
} | ||
|
||
func TestRulerAPISharding(t *testing.T) { | ||
testRulerAPIWithSharding(t, false) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/prometheus/common/model" | ||
"github.com/prometheus/prometheus/prompb" | ||
"github.com/stretchr/testify/require" | ||
|
||
|
@@ -105,16 +106,16 @@ overrides: | |
require.NoError(t, s.StartAndWaitReady(cortex)) | ||
|
||
// user-1 uses legacy validation | ||
user1Client, err := e2ecortex.NewClient(cortex.HTTPEndpoint(), "", "", "", "user-1") | ||
user1Client, err := e2ecortex.NewClient(cortex.HTTPEndpoint(), cortex.HTTPEndpoint(), "", "", "user-1") | ||
require.NoError(t, err) | ||
|
||
// user-2 uses utf8 validation | ||
user2Client, err := e2ecortex.NewClient(cortex.HTTPEndpoint(), "", "", "", "user-2") | ||
user2Client, err := e2ecortex.NewClient(cortex.HTTPEndpoint(), cortex.HTTPEndpoint(), "", "", "user-2") | ||
require.NoError(t, err) | ||
|
||
now := time.Now() | ||
|
||
utf8Series, _ := generateSeries("series_1", now, prompb.Label{Name: "test.utf8.metric", Value: "😄"}) | ||
utf8Series, _ := generateSeries("series.1", now, prompb.Label{Name: "test.utf8.metric", Value: "😄"}) | ||
legacySeries, _ := generateSeries("series_2", now, prompb.Label{Name: "job", Value: "test"}) | ||
|
||
res, err := user1Client.Push(legacySeries) | ||
|
@@ -134,4 +135,33 @@ overrides: | |
res, err = user2Client.Push(utf8Series) | ||
require.NoError(t, err) | ||
require.Equal(t, 200, res.StatusCode) | ||
|
||
// utf8 querying | ||
// c.f. https://prometheus.io/docs/guides/utf8/#querying | ||
query := `{"series.1", "test.utf8.metric"="😄"}` | ||
queryResult, err := user2Client.Query(query, now) | ||
require.NoError(t, err) | ||
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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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 |
||
|
||
// label names | ||
start := now | ||
end := now.Add(time.Minute * 5) | ||
labelNames, err := user2Client.LabelNames(start, end) | ||
require.NoError(t, err) | ||
require.Equal(t, []string{"__name__", "job", "test.utf8.metric"}, labelNames) | ||
|
||
// series | ||
series, err := user2Client.Series([]string{`{"test.utf8.metric"="😄"}`}, start, end) | ||
require.NoError(t, err) | ||
require.Equal(t, 1, len(series)) | ||
require.Equal(t, `{__name__="series.1", test.utf8.metric="😄"}`, series[0].String()) | ||
|
||
// label values | ||
labelValues, err := user2Client.LabelValues("test.utf8.metric", start, end, nil) | ||
require.NoError(t, err) | ||
require.Equal(t, 1, len(labelValues)) | ||
require.Equal(t, model.LabelValue("😄"), labelValues[0]) | ||
} |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
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.