mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Email: Allow configuration of content types for email notifications (#34530)
* Alerting: Allow configuration of content types for email notifications * Fix lint error * Improves email templates * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve code comments Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve email template * Remove unnecessary predeclaration Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Adds handling for unrecognized content type Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Move utility function outside of util package * Fixes syntax * Remove unused package * Fix lint error * improve email templates * Fix test * Alerting: Allow configuration of content types for email notifications * Fix lint error * Improves email templates * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve code comments Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve email template * Remove unnecessary predeclaration Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Adds handling for unrecognized content type Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Move utility function outside of util package * Fixes syntax * Remove unused package * Fix lint error * improve email templates * Fix test * Fix comment style Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> * Fix template formatting * Add test and improve error handling * Fix test * Fix formatting * Fix formatting * Improve documentation and regenerates txt template * Update docs/sources/administration/configuration.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Djairho Geuens <djairho.geuens@ae.be> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
@@ -6,10 +6,9 @@
|
||||
## Tasks
|
||||
|
||||
- npm run build (default task will build new inlines email templates)
|
||||
- npm start (will build on source html or css change)
|
||||
- npm start (builds on source HTML, text, or CSS change)
|
||||
|
||||
## Result
|
||||
|
||||
Assembled email templates will be in `dist/` and final
|
||||
inlined templates will be in `../public/emails/`
|
||||
|
||||
|
||||
@@ -2,15 +2,25 @@ module.exports = function () {
|
||||
'use strict';
|
||||
return {
|
||||
options: {
|
||||
layout: 'templates/layouts/default.html',
|
||||
partials: ['templates/partials/*.hbs'],
|
||||
helpers: ['templates/helpers/**/*.js'],
|
||||
data: [],
|
||||
flatten: true,
|
||||
},
|
||||
pages: {
|
||||
html: {
|
||||
options: {
|
||||
layout: 'templates/layouts/default.html',
|
||||
},
|
||||
src: ['templates/*.html'],
|
||||
dest: 'dist/',
|
||||
},
|
||||
txt: {
|
||||
options: {
|
||||
layout: 'templates/layouts/default.txt',
|
||||
ext: '.txt',
|
||||
},
|
||||
src: ['templates/*.txt'],
|
||||
dest: 'dist/',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
main: {
|
||||
html: {
|
||||
options: {
|
||||
verbose: true,
|
||||
removeComments: true,
|
||||
@@ -13,4 +13,19 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
txt: {
|
||||
options: {
|
||||
verbose: true,
|
||||
mode: 'txt',
|
||||
lineLength: 90,
|
||||
},
|
||||
files: [
|
||||
{
|
||||
expand: true, // Enable dynamic expansion.
|
||||
cwd: 'dist', // Src matches are relative to this path.
|
||||
src: ['*.txt'], // Actual patterns to match.
|
||||
dest: '../public/emails/', // Destination path prefix.
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
dist: {
|
||||
overwrite: true,
|
||||
src: ['dist/*.html'],
|
||||
src: ['dist/*.html', 'dist/*.txt'],
|
||||
replacements: [
|
||||
{
|
||||
from: '[[',
|
||||
|
||||
@@ -4,6 +4,7 @@ module.exports = {
|
||||
//what are the files that we want to watch
|
||||
'assets/css/*.css',
|
||||
'templates/**/*.html',
|
||||
'templates/**/*.txt',
|
||||
'grunt/*.js',
|
||||
],
|
||||
tasks: ['default'],
|
||||
|
||||
26
emails/templates/alert_notification.txt
Normal file
26
emails/templates/alert_notification.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
[[Subject .Subject "[[.Title]]"]]
|
||||
|
||||
[[.Title]]
|
||||
----------------
|
||||
|
||||
[[.Message]]
|
||||
|
||||
[[if ne .Error "" ]]
|
||||
Error message:
|
||||
[[.Error]]
|
||||
[[end]]
|
||||
|
||||
[[if ne .State "ok" ]]
|
||||
[[range .EvalMatches]]
|
||||
Metric name:
|
||||
[[.Metric]]
|
||||
Value:
|
||||
[[.Value]]
|
||||
[[end]]
|
||||
[[end]]
|
||||
|
||||
View your Alert rule:
|
||||
[[.RuleUrl]]"
|
||||
|
||||
Go to the Alerts page:
|
||||
[[.AlertPageUrl]]
|
||||
9
emails/templates/invited_to_org.txt
Normal file
9
emails/templates/invited_to_org.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
[[Subject .Subject "[[.InvitedBy]] has added you to the [[.OrgName]] organization"]]
|
||||
|
||||
You have been added to [[.OrgName]]
|
||||
|
||||
[[.InvitedBy]] has added you to the [[.OrgName]] organization in Grafana.
|
||||
Once logged in, [[.OrgName]] will be available in the left side menu, in the dropdown below your username.
|
||||
|
||||
Log in now:
|
||||
[[.AppUrl]]
|
||||
3
emails/templates/layouts/default.txt
Normal file
3
emails/templates/layouts/default.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
{{> body }}
|
||||
|
||||
Sent by Grafana v[[.BuildVersion]] (c) 2021 Grafana Labs
|
||||
@@ -39,7 +39,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="center">
|
||||
<p>You can also copy/paste this link into your browser directly: <a href="[[.LinkUrl]]">[[.LinkUrl]]</a></p>
|
||||
<p>You can also copy and paste this link into your browser directly: <a href="[[.LinkUrl]]">[[.LinkUrl]]</a></p>
|
||||
</td>
|
||||
<td class="expander"></td>
|
||||
</tr>
|
||||
|
||||
7
emails/templates/new_user_invite.txt
Normal file
7
emails/templates/new_user_invite.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
[[Subject .Subject "[[.InvitedBy]] has invited you to join Grafana"]]
|
||||
|
||||
You're invited to join [[.OrgName]]
|
||||
|
||||
You've been invited to join the [[.OrgName]] organization by [[.InvitedBy]]. To accept your invitation and join the team, copy and paste the link below into your browser directly:
|
||||
|
||||
[[.LinkUrl]]
|
||||
38
emails/templates/ng_alert_notification.txt
Normal file
38
emails/templates/ng_alert_notification.txt
Normal file
@@ -0,0 +1,38 @@
|
||||
[[Subject .Subject "[[.Title]]"]]
|
||||
|
||||
[[.Title]]
|
||||
----------------
|
||||
|
||||
[[ .Alerts | len ]] alert[[ if gt (len .Alerts) 1 ]]s[[ end ]] for
|
||||
[[ range .GroupLabels.SortedPairs ]]
|
||||
[[ .Name ]] = [[ .Value ]]
|
||||
[[ end ]]
|
||||
[[ if gt (len .Alerts.Firing) 0 ]]([[ .Alerts.Firing | len ]]) Firing[[ end ]]
|
||||
[[ range .Alerts.Firing ]]
|
||||
Labels:
|
||||
[[ range .Labels.SortedPairs ]]
|
||||
[[ .Name ]] = [[ .Value ]]
|
||||
[[ end ]]
|
||||
[[ if gt (len .Annotations) 0 ]]
|
||||
Annotations:
|
||||
[[ end ]]
|
||||
[[ range .Annotations.SortedPairs ]]
|
||||
[[ .Name ]] = [[ .Value ]]
|
||||
[[ end ]]
|
||||
[[ end ]][[ if gt (len .Alerts.Resolved) 0 ]]([[ .Alerts.Resolved | len ]]) Resolved[[ end ]]
|
||||
[[ range .Alerts.Resolved ]]
|
||||
Labels:
|
||||
[[ range .Labels.SortedPairs ]]
|
||||
[[ .Name ]] = [[ .Value ]]
|
||||
[[ end ]]
|
||||
[[ if gt (len .Annotations) 0 ]]
|
||||
Annotations:
|
||||
[[ end ]]
|
||||
[[ range .Annotations.SortedPairs ]]
|
||||
[[ .Name ]] = [[ .Value ]]
|
||||
[[ end ]]
|
||||
[[ end ]]View your Alert rule:
|
||||
[[.RuleUrl]]
|
||||
|
||||
Go to the Alerts page:
|
||||
[[.AlertPageUrl]]
|
||||
6
emails/templates/reset_password.txt
Normal file
6
emails/templates/reset_password.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
[[Subject .Subject "Reset your Grafana password - [[.Name]]"]]
|
||||
|
||||
Hi [[.Name]],
|
||||
|
||||
Copy and paste the following link directly in your browser to reset your password within [[.EmailCodeValidHours]] hours.
|
||||
[[.AppUrl]]user/password/reset?code=[[.Code]]
|
||||
9
emails/templates/signup_started.txt
Normal file
9
emails/templates/signup_started.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
[[Subject .Subject "Welcome to Grafana, please complete your sign up!"]]
|
||||
|
||||
Complete the signup
|
||||
|
||||
Copy and paste the email verification code:
|
||||
[[.Code]]
|
||||
in the sign up form or use the link below.
|
||||
|
||||
[[.SignUpUrl]]
|
||||
@@ -29,7 +29,7 @@
|
||||
<tr>
|
||||
<td class="center">
|
||||
<p>
|
||||
If you are new to Grafana please read the <a href="https://grafana.com/docs/grafana/latest/getting-started/getting-started/">Getting Started</a> guide.
|
||||
If you are new to Grafana, refer to the <a href="https://grafana.com/docs/grafana/latest/getting-started/getting-started/">Getting started with Grafana</a> guide.
|
||||
</p>
|
||||
</td>
|
||||
<td class="expander"></td>
|
||||
|
||||
11
emails/templates/welcome_on_signup.txt
Normal file
11
emails/templates/welcome_on_signup.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
[[Subject .Subject "Welcome to Grafana"]]
|
||||
|
||||
Hi [[.Name]],
|
||||
|
||||
Welcome! Ready to start building some beautiful metric and analytic dashboards?
|
||||
|
||||
If you are new to Grafana, refer to the Getting started with Grafana guide on https://grafana.com/docs/grafana/latest/getting-started/getting-started/.
|
||||
|
||||
Thank you for joining our community.
|
||||
|
||||
The Grafana team
|
||||
Reference in New Issue
Block a user