mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: introduce AlertRuleGroupKey and use it in API handlers (#48945)
* create AlertGroupKey structure * update PrometheusSrv. - extract creation of RuleGroup to a separate method. Use group key for grouping * update RuleSrv - update calculateChanges to use groupKey - authorize to use groupkey
This commit is contained in:
@@ -133,6 +133,15 @@ func GenerateAlertRules(count int, f func() *AlertRule) []*AlertRule {
|
||||
return result
|
||||
}
|
||||
|
||||
// GenerateGroupKey generates many random alert rules. Does not guarantee that rules are unique (by UID)
|
||||
func GenerateGroupKey(orgID int64) AlertRuleGroupKey {
|
||||
return AlertRuleGroupKey{
|
||||
OrgID: orgID,
|
||||
NamespaceUID: util.GenerateShortUID(),
|
||||
RuleGroup: util.GenerateShortUID(),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyRule creates a deep copy of AlertRule
|
||||
func CopyRule(r *AlertRule) *AlertRule {
|
||||
result := AlertRule{
|
||||
|
||||
Reference in New Issue
Block a user