Alerting: Only include image in notifier when enabled (#23194)

Fixes a bug when you had multiple notifiers for a rule, but not all 
had enabled to include image.

Fixes #22883
This commit is contained in:
Marcus Efraimsson
2020-03-31 00:46:01 +02:00
committed by GitHub
parent ea08c148df
commit 6bd7411f04
15 changed files with 55 additions and 44 deletions

View File

@@ -152,15 +152,17 @@ func (gcn *GoogleChatNotifier) Notify(evalContext *alerting.EvalContext) error {
}
widgets = append(widgets, fields)
// if an image exists, add it as an image widget
if evalContext.ImagePublicURL != "" {
widgets = append(widgets, imageWidget{
Image: image{
ImageURL: evalContext.ImagePublicURL,
},
})
} else {
gcn.log.Info("Could not retrieve a public image URL.")
if gcn.NeedsImage() {
// if an image exists, add it as an image widget
if evalContext.ImagePublicURL != "" {
widgets = append(widgets, imageWidget{
Image: image{
ImageURL: evalContext.ImagePublicURL,
},
})
} else {
gcn.log.Info("Could not retrieve a public image URL.")
}
}
// add a button widget (link to Grafana)