mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
Alerting: PagerDuty: adding current state to the payload (#29270)
* adding state to the payload * fix test * fix linter * documentation payload current state * Apply suggestions from code review Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
This commit is contained in:
parent
88ac1cf173
commit
bd0d051438
@ -129,7 +129,9 @@ This might break custom event rules in your PagerDuty rules if you rely on the f
|
||||
Move any existing rules using `custom_details.myMetric` to `custom_details.queries.myMetric`.
|
||||
This behavior will become the default in a future version of Grafana.
|
||||
|
||||
> Using `dedup_key` tag will override Grafana generated `dedup_key` with a custom key.
|
||||
> **Note:** The `dedup_key` tag overrides the Grafana-generated `dedup_key` with a custom key.
|
||||
|
||||
> **Note:** The `state` tag overrides the current alert state inside the `custom_details` payload.
|
||||
|
||||
### Pushover
|
||||
|
||||
|
@ -111,6 +111,7 @@ func (pn *PagerdutyNotifier) buildEventPayload(evalContext *alerting.EvalContext
|
||||
eventType = "resolve"
|
||||
}
|
||||
customData := simplejson.New()
|
||||
customData.Set("state", evalContext.Rule.State)
|
||||
if pn.MessageInDetails {
|
||||
queries := make(map[string]interface{})
|
||||
for _, evt := range evalContext.EvalMatches {
|
||||
|
@ -159,12 +159,14 @@ func TestPagerdutyNotifier(t *testing.T) {
|
||||
},
|
||||
},
|
||||
"payload": map[string]interface{}{
|
||||
"component": "Grafana",
|
||||
"source": "<<PRESENCE>>",
|
||||
"custom_details": map[string]interface{}{},
|
||||
"severity": "critical",
|
||||
"summary": "someRule - someMessage",
|
||||
"timestamp": "<<PRESENCE>>",
|
||||
"component": "Grafana",
|
||||
"source": "<<PRESENCE>>",
|
||||
"custom_details": map[string]interface{}{
|
||||
"state": "alerting",
|
||||
},
|
||||
"severity": "critical",
|
||||
"summary": "someRule - someMessage",
|
||||
"timestamp": "<<PRESENCE>>",
|
||||
},
|
||||
"routing_key": "abcdefgh0123456789",
|
||||
}, payload.Interface(), cmp.Comparer(presenceComparer))
|
||||
@ -231,6 +233,7 @@ func TestPagerdutyNotifier(t *testing.T) {
|
||||
"queries": map[string]interface{}{
|
||||
"someMetric": nil,
|
||||
},
|
||||
"state": "alerting",
|
||||
},
|
||||
"severity": "critical",
|
||||
"summary": "someRule",
|
||||
@ -303,6 +306,7 @@ func TestPagerdutyNotifier(t *testing.T) {
|
||||
"severity": "warning",
|
||||
"dedup_key": "key-" + strings.Repeat("x", 250),
|
||||
"keyOnly": "",
|
||||
"state": "alerting",
|
||||
},
|
||||
"severity": "warning",
|
||||
"summary": "someRule - someMessage",
|
||||
@ -380,6 +384,7 @@ func TestPagerdutyNotifier(t *testing.T) {
|
||||
"component": "aComponent",
|
||||
"severity": "info",
|
||||
"keyOnly": "",
|
||||
"state": "alerting",
|
||||
},
|
||||
"severity": "info",
|
||||
"summary": "someRule - someMessage",
|
||||
@ -458,6 +463,7 @@ func TestPagerdutyNotifier(t *testing.T) {
|
||||
"component": "aComponent",
|
||||
"severity": "llama",
|
||||
"keyOnly": "",
|
||||
"state": "alerting",
|
||||
},
|
||||
"severity": "critical",
|
||||
"summary": "someRule - someMessage",
|
||||
|
Loading…
Reference in New Issue
Block a user