Explorar o código

Merge pull request #11046 from llamashoes/master

Add metrics that triggered alert to description in OpsGenie.
Carl Bergquist %!s(int64=7) %!d(string=hai) anos
pai
achega
c39e68de24
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      pkg/services/alerting/notifiers/opsgenie.go

+ 6 - 1
pkg/services/alerting/notifiers/opsgenie.go

@@ -99,11 +99,16 @@ func (this *OpsGenieNotifier) createAlert(evalContext *alerting.EvalContext) err
 		return err
 		return err
 	}
 	}
 
 
+	customData := "Triggered metrics:\n\n"
+	for _, evt := range evalContext.EvalMatches {
+		customData = customData + fmt.Sprintf("%s: %v\n", evt.Metric, evt.Value)
+	}
+
 	bodyJSON := simplejson.New()
 	bodyJSON := simplejson.New()
 	bodyJSON.Set("message", evalContext.Rule.Name)
 	bodyJSON.Set("message", evalContext.Rule.Name)
 	bodyJSON.Set("source", "Grafana")
 	bodyJSON.Set("source", "Grafana")
 	bodyJSON.Set("alias", "alertId-"+strconv.FormatInt(evalContext.Rule.Id, 10))
 	bodyJSON.Set("alias", "alertId-"+strconv.FormatInt(evalContext.Rule.Id, 10))
-	bodyJSON.Set("description", fmt.Sprintf("%s - %s\n%s", evalContext.Rule.Name, ruleUrl, evalContext.Rule.Message))
+	bodyJSON.Set("description", fmt.Sprintf("%s - %s\n%s\n%s", evalContext.Rule.Name, ruleUrl, evalContext.Rule.Message, customData))
 
 
 	details := simplejson.New()
 	details := simplejson.New()
 	details.Set("url", ruleUrl)
 	details.Set("url", ruleUrl)