Commit 544073b7 by bergquist

feat(alerting): make sure saved alerts are valid

parent a1f97e0b
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment