Alerting: Migration to fix rule group name to not contain slashes + make all groups unique #65662
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.
What is this feature?
When Grafana migrates rules from legacy alerting it creates a new rule with title and group name taken from the legacy alert title. There are no restrictions on the rule title in the legacy alerting but there are constraints for the rule group in the new alerting: the name cannot contain forward or backward slashes
This PR fixes migration to normalize group name and replaces slashes with
_
.This can cause another problem - two rules with names like
rule1 // test
andrule1 /\ test
will end up in the same grouprule1 __ test
and if rules have different evaluation intervals, the evaluation interval of one rule will override another. Also, it brakes the contract that during migration a rule is placed in its own group.To make sure that all groups are unique, this PR updates migration to check all rules in the organization for the uniqueness of the group. If group name is not unique, it is modified by appending rule UID at the end of the name (if the concatenated string is longer than the maximum limit of 190 symbols, the group name gets truncated to fit the full UID).
Related: #55670 (comment)
Please check that: