mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
Alerting: Also include configured AlertRuleTags in Webhooks (#18233)
* added alert rule tags in webhook notifications * fix: don't include whole list of Tag objects but only key/value pairs in Webhook JSON * marked webhook alerts to support alert rule tags
This commit is contained in:
parent
e8790c32ca
commit
32d6740b8f
@ -186,7 +186,7 @@ Slack | `slack` | yes | no
|
|||||||
Telegram | `telegram` | yes | no
|
Telegram | `telegram` | yes | no
|
||||||
Threema | `threema` | yes, external only | no
|
Threema | `threema` | yes, external only | no
|
||||||
VictorOps | `victorops` | yes, external only | no
|
VictorOps | `victorops` | yes, external only | no
|
||||||
Webhook | `webhook` | yes, external only | no
|
Webhook | `webhook` | yes, external only | yes
|
||||||
|
|
||||||
# Enable images in notifications {#external-image-store}
|
# Enable images in notifications {#external-image-store}
|
||||||
|
|
||||||
|
@ -81,6 +81,14 @@ func (wn *WebhookNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
bodyJSON.Set("state", evalContext.Rule.State)
|
bodyJSON.Set("state", evalContext.Rule.State)
|
||||||
bodyJSON.Set("evalMatches", evalContext.EvalMatches)
|
bodyJSON.Set("evalMatches", evalContext.EvalMatches)
|
||||||
|
|
||||||
|
tags := make(map[string]string)
|
||||||
|
|
||||||
|
for _, tag := range evalContext.Rule.AlertRuleTags {
|
||||||
|
tags[tag.Key] = tag.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
bodyJSON.Set("tags", tags)
|
||||||
|
|
||||||
ruleURL, err := evalContext.GetRuleURL()
|
ruleURL, err := evalContext.GetRuleURL()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
bodyJSON.Set("ruleUrl", ruleURL)
|
bodyJSON.Set("ruleUrl", ruleURL)
|
||||||
|
Loading…
Reference in New Issue
Block a user