Alerting: Upload error image when image renderer unavailable (#23713)

When Include image is enabled for an alert notification channel, but there's 
no image renderer available/installed when sending notification an error 
image will be uploaded/attached explaining that you need to install the 
Grafana Image Renderer plugin.

Ref #13802

Co-Authored-By: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Marcus Efraimsson
2020-04-24 11:35:55 +02:00
committed by GitHub
co-authored by Arve Knudsen
parent 98df2ec745
commit 58de0dabd4
4 changed files with 28 additions and 22 deletions
+13 -2
View File
@@ -121,6 +121,14 @@ func (rs *RenderingService) RenderErrorImage(err error) (*RenderResult, error) {
}, nil
}
func (rs *RenderingService) renderUnavailableImage() *RenderResult {
imgPath := "public/img/rendering_plugin_not_installed.png"
return &RenderResult{
FilePath: filepath.Join(setting.HomePath, imgPath),
}
}
func (rs *RenderingService) Render(ctx context.Context, opts Opts) (*RenderResult, error) {
if rs.inProgressCount > opts.ConcurrentLimit {
return &RenderResult{
@@ -128,8 +136,11 @@ func (rs *RenderingService) Render(ctx context.Context, opts Opts) (*RenderResul
}, nil
}
if rs.renderAction == nil {
return nil, fmt.Errorf("no renderer found")
if !rs.IsAvailable() {
rs.log.Warn("Could not render image, no image renderer found/installed. " +
"For image rendering support please install the grafana-image-renderer plugin. " +
"Read more at https://grafana.com/docs/grafana/latest/administration/image_rendering/")
return rs.renderUnavailableImage(), nil
}
rs.log.Info("Rendering", "path", opts.Path)