2024-02-07 11:55:48 -06:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/grafana/grafana/pkg/util/errutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
errAlertRuleConflictMsg = "conflicting alert rule found [rule_uid: '{{ .Public.RuleUID }}', title: '{{ .Public.Title }}', namespace_uid: '{{ .Public.NamespaceUID }}']: {{ .Public.Error }}"
|
|
|
|
ErrAlertRuleConflictBase = errutil.Conflict("alerting.alert-rule.conflict").
|
|
|
|
MustTemplate(errAlertRuleConflictMsg, errutil.WithPublic(errAlertRuleConflictMsg))
|
2024-04-05 09:20:21 -05:00
|
|
|
ErrAlertRuleGroupNotFound = errutil.NotFound("alerting.alert-rule.notFound")
|
|
|
|
ErrInvalidRelativeTimeRangeBase = errutil.BadRequest("alerting.alert-rule.invalidRelativeTime").MustTemplate("Invalid alert rule query {{ .Public.RefID }}: invalid relative time range [From: {{ .Public.From }}, To: {{ .Public.To }}]")
|
2024-02-07 11:55:48 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func ErrAlertRuleConflict(rule AlertRule, underlying error) error {
|
|
|
|
return ErrAlertRuleConflictBase.Build(errutil.TemplateData{Public: map[string]any{"RuleUID": rule.UID, "Title": rule.Title, "NamespaceUID": rule.NamespaceUID, "Error": underlying.Error()}, Error: underlying})
|
|
|
|
}
|
2024-04-05 09:20:21 -05:00
|
|
|
|
|
|
|
func ErrInvalidRelativeTimeRange(refID string, rtr RelativeTimeRange) error {
|
|
|
|
return ErrInvalidRelativeTimeRangeBase.Build(errutil.TemplateData{Public: map[string]any{"RefID": refID, "From": rtr.From, "To": rtr.To}})
|
|
|
|
}
|