feat: support group-level labels for rule-group resources - #75
Merged
Conversation
sandrom
force-pushed
the
feat/group-level-labels
branch
2 times, most recently
from
June 29, 2026 14:18
c92b1ea to
d2ec0c2
Compare
Add a group-level `labels` map to mimir_rule_group_alerting, mimir_rule_group_recording, and the combined mimir_rules resource. Group labels are applied to all rules in a group (e.g. for notification routing) and were previously dropped by the provider. - typed resources: new optional `labels` TypeMap, expanded in Create/Update, included in the HasChanges gate, and read back in Read for a drift-free round-trip. - mimir_rules: add the `Labels` field to the RuleGroup struct so group-level labels in the YAML content reach the backend (POST body) and the content hash. Group-level labels require Mimir >= 3.0.0 to be persisted; older Mimir accepts but silently drops them. This is documented on the schema attribute descriptions. Adds version-gated acceptance tests (skipped below 3.0.0) for all three resources plus a unit round-trip test; passes make testacc on Mimir 3.0.6 and 2.17.10. Refs: EDPIPIF-1516 Signed-off-by: Sandro Manke <hello@sandrom.de>
sandrom
force-pushed
the
feat/group-level-labels
branch
from
June 29, 2026 14:21
d2ec0c2 to
36da7ef
Compare
sandrom
marked this pull request as ready for review
June 29, 2026 14:23
Owner
|
Oh nice thanks @sandrom |
fgouteroux
self-requested a review
June 30, 2026 17:58
fgouteroux
approved these changes
Jun 30, 2026
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.
Summary
Adds support for group-level
labelson rule-group resources. A rule group can carry labels applied to all of its rules (commonly used for notification routing, e.g.target_channel). Previously the provider dropped group-level labels entirely.This covers all three rule-group resources:
mimir_rule_group_alerting/mimir_rule_group_recording(typed): new optional top-levellabelsmap (TypeMap), expanded into the group on Create/Update, included in theHasChangesgate so a label-only edit triggers an update, and set back from the API on Read for a drift-free round-trip.mimir_rules(combined YAML): adds theLabelsfield to theRuleGroupstruct so a group-levellabels:key in the YAMLcontent/content_filereaches the backend (POST body) and the content hash, instead of being silently dropped on unmarshal.Version requirement
Group-level rule-group labels are only persisted by Mimir >= 3.0.0 (Prometheus added the
rulefmtgroupLabelsfield in 3.0.0; Mimir's ruler honours it from 3.0.0). On older Mimir the config API accepts the labels but drops them. This is documented on each schema attribute's description. On a typed resource against Mimir < 3.0.0 this means a non-converging plan (the server returns no labels); the requirement is documented rather than enforced at runtime.Tests
TestRuleGroupContentPreservesGroupLabels— group labels survive the parse → marshal round-trip used by Create and the content hash.TestAccResourceRuleGroupAlerting_GroupLabels,TestAccResourceRuleGroupRecording_GroupLabels,TestAccResourceMimirRules_GroupLabels— create without labels, add labels (exercises theHasChangesgate), change the value, and (formimir_rules) assert via the ruler API + a no-drift re-apply.make testaccpasses on Mimir 3.0.6 and 2.17.10 (the group-label tests--- SKIPon 2.17.10);golangci-lintclean; docs regenerated viatfplugindocs.