Commit 4526660c by bergquist

wire up debounce setting in the ui

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