Commit 4526660c by bergquist

wire up debounce setting in the ui

parent 2d3a5754
...@@ -2,6 +2,7 @@ package alerting ...@@ -2,6 +2,7 @@ package alerting
import ( import (
"errors" "errors"
"time"
"fmt" "fmt"
...@@ -113,15 +114,25 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json, ...@@ -113,15 +114,25 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json,
return nil, ValidationError{Reason: "Could not parse frequency"} return nil, ValidationError{Reason: "Could not parse frequency"}
} }
rawDebouce := jsonAlert.Get("debounceDuration").MustString()
var debounceDuration time.Duration
if rawDebouce != "" {
debounceDuration, err = time.ParseDuration(rawDebouce)
if err != nil {
return nil, ValidationError{Reason: "Could not parse debounceDuration"}
}
}
alert := &m.Alert{ alert := &m.Alert{
DashboardId: e.Dash.Id, DashboardId: e.Dash.Id,
OrgId: e.OrgID, OrgId: e.OrgID,
PanelId: panelID, PanelId: panelID,
Id: jsonAlert.Get("id").MustInt64(), Id: jsonAlert.Get("id").MustInt64(),
Name: jsonAlert.Get("name").MustString(), Name: jsonAlert.Get("name").MustString(),
Handler: jsonAlert.Get("handler").MustInt64(), Handler: jsonAlert.Get("handler").MustInt64(),
Message: jsonAlert.Get("message").MustString(), Message: jsonAlert.Get("message").MustString(),
Frequency: frequency, Frequency: frequency,
DebounceDuration: debounceDuration,
} }
for _, condition := range jsonAlert.Get("conditions").MustArray() { for _, condition := range jsonAlert.Get("conditions").MustArray() {
......
...@@ -193,7 +193,8 @@ func updateAlerts(existingAlerts []*m.Alert, cmd *m.SaveAlertsCommand, sess *DBS ...@@ -193,7 +193,8 @@ func updateAlerts(existingAlerts []*m.Alert, cmd *m.SaveAlertsCommand, sess *DBS
if alertToUpdate.ContainsUpdates(alert) { if alertToUpdate.ContainsUpdates(alert) {
alert.Updated = timeNow() alert.Updated = timeNow()
alert.State = alertToUpdate.State alert.State = alertToUpdate.State
sess.MustCols("message") sess.MustCols("message", "debounce_duration")
_, err := sess.ID(alert.Id).Update(alert) _, err := sess.ID(alert.Id).Update(alert)
if err != nil { if err != nil {
return err return err
......
...@@ -169,6 +169,7 @@ export class AlertTabCtrl { ...@@ -169,6 +169,7 @@ export class AlertTabCtrl {
alert.frequency = alert.frequency || '1m'; alert.frequency = alert.frequency || '1m';
alert.handler = alert.handler || 1; alert.handler = alert.handler || 1;
alert.notifications = alert.notifications || []; alert.notifications = alert.notifications || [];
alert.debounceDuration = alert.debounceDuration || '5m';
const defaultName = this.panel.title + ' alert'; const defaultName = this.panel.title + ' alert';
alert.name = alert.name || defaultName; alert.name = alert.name || defaultName;
......
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