mirror of https://github.com/grafana/grafana.git
Merge pull request #9311 from ctrlok/ctrlok/pagerdutyinfo
Include triggering metrics to pagerduty alerts (pretty print)
This commit is contained in:
commit
8a7f87b752
|
|
@ -3,6 +3,8 @@ package notifiers
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||||
"github.com/grafana/grafana/pkg/log"
|
"github.com/grafana/grafana/pkg/log"
|
||||||
|
|
@ -72,6 +74,10 @@ func (this *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||||
if evalContext.Rule.State == m.AlertStateOK {
|
if evalContext.Rule.State == m.AlertStateOK {
|
||||||
eventType = "resolve"
|
eventType = "resolve"
|
||||||
}
|
}
|
||||||
|
customData := "Triggered metrics:\n\n"
|
||||||
|
for _, evt := range evalContext.EvalMatches {
|
||||||
|
customData = customData + fmt.Sprintf("%s: %v\n", evt.Metric, evt.Value)
|
||||||
|
}
|
||||||
|
|
||||||
this.log.Info("Notifying Pagerduty", "event_type", eventType)
|
this.log.Info("Notifying Pagerduty", "event_type", eventType)
|
||||||
|
|
||||||
|
|
@ -79,6 +85,7 @@ func (this *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||||
bodyJSON.Set("service_key", this.Key)
|
bodyJSON.Set("service_key", this.Key)
|
||||||
bodyJSON.Set("description", evalContext.Rule.Name+" - "+evalContext.Rule.Message)
|
bodyJSON.Set("description", evalContext.Rule.Name+" - "+evalContext.Rule.Message)
|
||||||
bodyJSON.Set("client", "Grafana")
|
bodyJSON.Set("client", "Grafana")
|
||||||
|
bodyJSON.Set("details", customData)
|
||||||
bodyJSON.Set("event_type", eventType)
|
bodyJSON.Set("event_type", eventType)
|
||||||
bodyJSON.Set("incident_key", "alertId-"+strconv.FormatInt(evalContext.Rule.Id, 10))
|
bodyJSON.Set("incident_key", "alertId-"+strconv.FormatInt(evalContext.Rule.Id, 10))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue