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:
William Wernert
2024-09-20 00:27:37 +03:00
committed by GitHub
parent 9a40e8dca6
commit f1ba7deff5
2 changed files with 29 additions and 0 deletions
+11
View File
@@ -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"
}