Alerting: Also clear fields in model/store validation for recording rules (#93506)
* Fix model validation * Remove validation from provisioning service
This commit is contained in:
@@ -610,9 +610,20 @@ func validateRecordingRuleFields(rule *AlertRule) error {
|
||||
if !prommodels.IsValidMetricName(metricName) {
|
||||
return fmt.Errorf("%w: %s", ErrAlertRuleFailedValidation, "metric name for recording rule must be a valid Prometheus metric name")
|
||||
}
|
||||
|
||||
clearRecordingRuleIgnoredFields(rule)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func clearRecordingRuleIgnoredFields(rule *AlertRule) {
|
||||
rule.NoDataState = ""
|
||||
rule.ExecErrState = ""
|
||||
rule.Condition = ""
|
||||
rule.For = 0
|
||||
rule.NotificationSettings = nil
|
||||
}
|
||||
|
||||
func (alertRule *AlertRule) ResourceType() string {
|
||||
return "alertRule"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user