mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): make sure saved alerts are valid
This commit is contained in:
parent
a1f97e0b77
commit
544073b7e1
@ -27,6 +27,10 @@ type AlertRule struct {
|
||||
Updated time.Time `json:"updated"`
|
||||
}
|
||||
|
||||
func (alertRule *AlertRule) ValidToSave() bool {
|
||||
return alertRule.Query != "" && alertRule.Frequency != 0 && alertRule.QueryRange != 0 && alertRule.Name != ""
|
||||
}
|
||||
|
||||
func (this *AlertRule) Equals(other *AlertRule) bool {
|
||||
result := false
|
||||
|
||||
|
@ -65,7 +65,7 @@ func ParseAlertsFromDashboard(cmd *m.SaveDashboardCommand) []*m.AlertRule {
|
||||
alert.DatasourceId = query.Result.Id
|
||||
}
|
||||
|
||||
if alert.Query != "" {
|
||||
if alert.ValidToSave() {
|
||||
alerts = append(alerts, alert)
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ func (arr *AlertRuleReader) Fetch() []*AlertRule {
|
||||
model.Description = ruleDef.Description
|
||||
model.Aggregator = ruleDef.Aggregator
|
||||
model.State = ruleDef.State
|
||||
model.QueryRange = ruleDef.QueryRange
|
||||
res[i] = model
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user