Explorar o código

Resolve rebase w/ upstream conflicts.
Remove: `Alert on Exec Error` (no longer needed)
Add: `ruleUrl` to VictorOps message body.

ichekrygin %!s(int64=9) %!d(string=hai) anos
pai
achega
8f0d51171d

+ 10 - 8
pkg/services/alerting/notifiers/victorops.go

@@ -49,9 +49,15 @@ type VictoropsNotifier struct {
 
 
 // Notify sends notification to Victorops via POST to URL endpoint
 // Notify sends notification to Victorops via POST to URL endpoint
 func (this *VictoropsNotifier) Notify(evalContext *alerting.EvalContext) error {
 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)
 	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)
 	fields := make([]map[string]interface{}, 0)
 	fieldLimitCount := 4
 	fieldLimitCount := 4
 	for index, evt := range evalContext.EvalMatches {
 	for index, evt := range evalContext.EvalMatches {
@@ -78,23 +84,19 @@ func (this *VictoropsNotifier) Notify(evalContext *alerting.EvalContext) error {
 		messageType = AlertStateCritical
 		messageType = AlertStateCritical
 	}
 	}
 
 
-	if evalContext.Rule.State == models.AlertStateExecError && !this.AlertOnExecError {
-		return nil
-	}
-
 	body := map[string]interface{}{
 	body := map[string]interface{}{
 		"message_type":     messageType,
 		"message_type":     messageType,
 		"entity_id":        evalContext.Rule.Name,
 		"entity_id":        evalContext.Rule.Name,
 		"timestamp":        time.Now().Unix(),
 		"timestamp":        time.Now().Unix(),
 		"state_start_time": evalContext.StartTime.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,
 		"monitoring_tool":  "Grafana v" + setting.BuildVersion,
 	}
 	}
 
 
 	data, _ := json.Marshal(&body)
 	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)
 		this.log.Error("Failed to send victorops notification", "error", err, "webhook", this.Name)
 	}
 	}
 
 

+ 0 - 9
public/app/features/alerting/partials/notification_edit.html

@@ -93,15 +93,6 @@
         <span class="gf-form-label width-6">Url</span>
         <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>
         <input type="text" required class="gf-form-input max-width-30" ng-model="ctrl.model.settings.url" placeholder="Victorops url"></input>
       </div>
       </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>
 
 
     <div class="gf-form-group section" ng-if="ctrl.model.type === 'email'">
     <div class="gf-form-group section" ng-if="ctrl.model.type === 'email'">