Resolve rebase w/ upstream conflicts.

Remove: `Alert on Exec Error` (no longer needed)
Add: `ruleUrl` to VictorOps message body.
This commit is contained in:
ichekrygin 2016-11-16 16:13:33 -08:00
parent bbca9861fb
commit 8f0d51171d
2 changed files with 10 additions and 17 deletions

View File

@ -49,9 +49,15 @@ type VictoropsNotifier struct {
// Notify sends notification to Victorops via POST to URL endpoint
func (this *VictoropsNotifier) Notify(evalContext *alerting.EvalContext) error {
this.log.Info("Executing victorops notification", "ruleId", evalContext.Rule.Id, "notification")
this.log.Info("Executing victorops notification", "ruleId", evalContext.Rule.Id, "notification", this.Name)
metrics.M_Alerting_Notification_Sent_Victorops.Inc(1)
ruleUrl, err := evalContext.GetRuleUrl()
if err != nil {
this.log.Error("Failed get rule link", "error", err)
return err
}
fields := make([]map[string]interface{}, 0)
fieldLimitCount := 4
for index, evt := range evalContext.EvalMatches {
@ -78,23 +84,19 @@ func (this *VictoropsNotifier) Notify(evalContext *alerting.EvalContext) error {
messageType = AlertStateCritical
}
if evalContext.Rule.State == models.AlertStateExecError && !this.AlertOnExecError {
return nil
}
body := map[string]interface{}{
"message_type": messageType,
"entity_id": evalContext.Rule.Name,
"timestamp": time.Now().Unix(),
"state_start_time": evalContext.StartTime.Unix(),
"state_message": evalContext.Rule.Message,
"state_message": evalContext.Rule.Message + "\n" + ruleUrl,
"monitoring_tool": "Grafana v" + setting.BuildVersion,
}
data, _ := json.Marshal(&body)
cmd := &models.SendWebhook{Url: this.URL, Body: string(data)}
cmd := &models.SendWebhookSync{Url: this.URL, Body: string(data)}
if err := bus.Dispatch(cmd); err != nil {
if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {
this.log.Error("Failed to send victorops notification", "error", err, "webhook", this.Name)
}

View File

@ -93,15 +93,6 @@
<span class="gf-form-label width-6">Url</span>
<input type="text" required class="gf-form-input max-width-30" ng-model="ctrl.model.settings.url" placeholder="Victorops url"></input>
</div>
<div class="gf-form">
<gf-form-switch
class="gf-form"
label="Alert on Exec Error"
label-class="width-12"
checked="ctrl.model.settings.alertOnExecError"
tooltip="Trigger incident on Execution Error">
</gf-form-switch>
</div>
</div>
<div class="gf-form-group section" ng-if="ctrl.model.type === 'email'">