Commit 4526660c by bergquist

wire up debounce setting in the ui

parent 2d3a5754
......@@ -2,6 +2,7 @@ package alerting
import (
"errors"
"time"
"fmt"
......@@ -113,6 +114,15 @@ 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,
......@@ -122,6 +132,7 @@ func (e *DashAlertExtractor) getAlertFromPanels(jsonWithPanels *simplejson.Json,
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;
......
......@@ -28,9 +28,21 @@
<h5 class="section-heading">Alert Config</h5>
<div class="gf-form">
<span class="gf-form-label width-6">Name</span>
<input type="text" class="gf-form-input width-20" ng-model="ctrl.alert.name">
<span class="gf-form-label">Evaluate every</span>
<input class="gf-form-input max-width-5" type="text" ng-model="ctrl.alert.frequency"></input>
<input type="text" class="gf-form-input width-22" ng-model="ctrl.alert.name">
</div>
<div class="gf-form-inline">
<div class="gf-form">
<span class="gf-form-label width-8">Evaluate every</span>
<input class="gf-form-input max-width-5" type="text" ng-model="ctrl.alert.frequency">
</div>
<div class="gf-form max-width-15">
<label class="gf-form-label width-10">Debounce duration</label>
<input type="text" class="gf-form-input max-width-5" ng-model="ctrl.alert.debounceDuration" spellcheck='false' placeholder="5m">
<info-popover mode="right-absolute">
Configuring this value means that an alert rule have to be firing for atleast this duration before changing state.
This should reduce false positive alerts and avoid flapping alerts.
</info-popover>
</div>
</div>
</div>
......
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