mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Truncate PagerDuty summary when greater than 1024 characters (#18730)
Requests to PagerDuty fail with an HTTP 400 if the `summary` attribute contains more than 1024 characters, this fixes this. API spec: https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2 Fixes #18727
This commit is contained in:
committed by
Marcus Efraimsson
parent
54ebf174a0
commit
8a991244d5
@@ -88,7 +88,13 @@ func (pn *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
pn.log.Info("Notifying Pagerduty", "event_type", eventType)
|
pn.log.Info("Notifying Pagerduty", "event_type", eventType)
|
||||||
|
|
||||||
payloadJSON := simplejson.New()
|
payloadJSON := simplejson.New()
|
||||||
payloadJSON.Set("summary", evalContext.Rule.Name+" - "+evalContext.Rule.Message)
|
|
||||||
|
summary := evalContext.Rule.Name + " - " + evalContext.Rule.Message
|
||||||
|
if len(summary) > 1024 {
|
||||||
|
summary = summary[0:1024]
|
||||||
|
}
|
||||||
|
payloadJSON.Set("summary", summary)
|
||||||
|
|
||||||
if hostname, err := os.Hostname(); err == nil {
|
if hostname, err := os.Hostname(); err == nil {
|
||||||
payloadJSON.Set("source", hostname)
|
payloadJSON.Set("source", hostname)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user