Skip to content

Add support for rule group labels #6665

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

Merged
merged 3 commits into from
Apr 20, 2025

Conversation

mustafain117
Copy link
Contributor

@mustafain117 mustafain117 commented Mar 24, 2025

What this PR does:
Adds support for labels at rule group level.

Which issue(s) this PR fixes:

This feature was added in a recent Prometheus release, cortex should support this.
related PR: prometheus/prometheus#11474

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@dosubot dosubot bot added the component/rules Bits & bobs todo with rules and alerts: the ruler, config service etc. label Mar 24, 2025
@mustafain117 mustafain117 force-pushed the rule-group-labels branch 3 times, most recently from 49e9849 to c469509 Compare March 27, 2025 18:28
@@ -30,6 +30,10 @@ message RuleGroupDesc {
int64 limit =10;
google.protobuf.Duration queryOffset = 11
[(gogoproto.nullable) = true, (gogoproto.stdduration) = true];
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated, but interesting that queryOffset is using nullable = true while all the rest is not. I was reading through the implications https://pkg.go.dev/github.com/gogo/protobuf/gogoproto#hdr-More_Canonical_Go_Structures

// Wait until ruler has loaded the group.
require.NoError(t, ruler.WaitSumMetricsWithOptions(e2e.Equals(1), []string{"cortex_prometheus_rule_group_rules"}, e2e.WithLabelMatchers(m), e2e.WaitMissingMetrics))

groups, _, err := c.GetPrometheusRules(e2ecortex.RuleFilter{
Copy link
Contributor

Choose a reason for hiding this comment

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

we could also get the rule group using the client GerRuleGroup method to assert that the duplicate_label is really in the rule group level.

@rapphil
Copy link
Contributor

rapphil commented Mar 28, 2025

LGTM. Thanks!

Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Group: &rulespb.RuleGroupDesc{

I wonder if we miss this one. When API backup is enabled.

@@ -1739,6 +1739,106 @@ func TestRulerEvalWithQueryFrontend(t *testing.T) {
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try to cover group labels in the API backup test case? Just to make sure it works for that scenario

TestRulerAPIShardingWithAPIRulesBackupEnabled

Signed-off-by: Mustafain Ali Khan <mustalik@amazon.com>
Signed-off-by: Mustafain Ali Khan <mustalik@amazon.com>
Signed-off-by: Mustafain Ali Khan <mustalik@amazon.com>
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Thanks!

@yeya24 yeya24 merged commit 0e85ae0 into cortexproject:master Apr 20, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/rules Bits & bobs todo with rules and alerts: the ruler, config service etc. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants