mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
Add values to the hipchat card
This commit is contained in:
parent
c6f7d34c55
commit
9666f45e9c
@ -84,15 +84,13 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||
return err
|
||||
}
|
||||
|
||||
message := evalContext.GetNotificationTitle() + " in state " + evalContext.GetStateModel().Text + "<br><a href=" + ruleUrl + ">Check Dasboard</a>"
|
||||
fields := make([]map[string]interface{}, 0)
|
||||
message += "<br>"
|
||||
attributes := make([]map[string]interface{}, 0)
|
||||
for index, evt := range evalContext.EvalMatches {
|
||||
message += evt.Metric + " :: " + strconv.FormatFloat(evt.Value.Float64, 'f', -1, 64) + "<br>"
|
||||
fields = append(fields, map[string]interface{}{
|
||||
"title": evt.Metric,
|
||||
"value": evt.Value,
|
||||
"short": true,
|
||||
attributes = append(attributes, map[string]interface{}{
|
||||
"label": evt.Metric,
|
||||
"value": map[string]interface{}{
|
||||
"label": strconv.FormatFloat(evt.Value.Float64, 'f', -1, 64),
|
||||
},
|
||||
})
|
||||
if index > maxFieldCount {
|
||||
break
|
||||
@ -100,13 +98,15 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||
}
|
||||
|
||||
if evalContext.Error != nil {
|
||||
fields = append(fields, map[string]interface{}{
|
||||
"title": "Error message",
|
||||
"value": evalContext.Error.Error(),
|
||||
"short": false,
|
||||
attributes = append(attributes, map[string]interface{}{
|
||||
"label": "Error message",
|
||||
"value": map[string]interface{}{
|
||||
"label": evalContext.Error.Error(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
message := ""
|
||||
if evalContext.Rule.State != models.AlertStateOK { //dont add message when going back to alert state ok.
|
||||
message += " " + evalContext.Rule.Message
|
||||
}
|
||||
@ -123,15 +123,16 @@ func (this *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||
|
||||
// Add a card with link to the dashboard
|
||||
card := map[string]interface{}{
|
||||
"style": "link",
|
||||
"style": "application",
|
||||
"url": ruleUrl,
|
||||
"id": "1",
|
||||
"title": evalContext.GetNotificationTitle(),
|
||||
"description": evalContext.GetNotificationTitle() + " in state " + evalContext.GetStateModel().Text,
|
||||
"description": message,
|
||||
"icon": map[string]interface{}{
|
||||
"url": "https://grafana.com/assets/img/fav32.png",
|
||||
},
|
||||
"date": evalContext.EndTime.Unix(),
|
||||
"date": evalContext.EndTime.Unix(),
|
||||
"attributes": attributes,
|
||||
}
|
||||
|
||||
body := map[string]interface{}{
|
||||
|
Loading…
Reference in New Issue
Block a user