mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Add image url or file attachment to email notifications. (#49381)
If an image token is present in an alert instance, the email notifier will attempt to find a public URL for the image token. If found, it will add that to the email as the `ImageLink` field. If only local file data is available, the notifier will attach the file to the outgoing email using the `EmbeddedImage` field.
This commit is contained in:
@@ -41,6 +41,8 @@ type ImageStore interface {
|
||||
|
||||
GetURL(ctx context.Context, token string) (string, error)
|
||||
|
||||
GetFilepath(ctx context.Context, token string) (string, error)
|
||||
|
||||
// Returns an io.ReadCloser that reads out the image data for the provided
|
||||
// token, if available. May return ErrImageNotFound.
|
||||
GetData(ctx context.Context, token string) (io.ReadCloser, error)
|
||||
@@ -99,6 +101,14 @@ func (st *DBstore) GetURL(ctx context.Context, token string) (string, error) {
|
||||
return img.URL, nil
|
||||
}
|
||||
|
||||
func (st *DBstore) GetFilepath(ctx context.Context, token string) (string, error) {
|
||||
img, err := st.GetImage(ctx, token)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return img.Path, nil
|
||||
}
|
||||
|
||||
func (st *DBstore) GetData(ctx context.Context, token string) (io.ReadCloser, error) {
|
||||
// TODO: Should we support getting data from image.URL? One could configure
|
||||
// the system to upload to S3 while still reading data for notifiers like
|
||||
|
||||
Reference in New Issue
Block a user