feat(alerting): improve email notifications layout

This commit is contained in:
bergquist
2016-08-13 11:24:03 +02:00
parent 74dbd7fb36
commit c4e905474a
6 changed files with 124 additions and 33 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ func (e *Engine) alertingTicker() {
func (e *Engine) execDispatcher() {
for job := range e.execQueue {
e.log.Debug("Starting executing alert rule %s", job.Rule.Name)
e.log.Debug("Starting executing alert rule", "alert id", job.Rule.Id)
go e.executeJob(job)
}
}
+1 -1
View File
@@ -100,6 +100,6 @@ func NewEvalContext(rule *Rule) *EvalContext {
Events: make([]*Event, 0),
DoneChan: make(chan bool, 1),
CancelChan: make(chan bool, 1),
log: log.New("alerting.engine"),
log: log.New("alerting.evalContext"),
}
}
+9 -5
View File
@@ -8,6 +8,7 @@ import (
"github.com/grafana/grafana/pkg/metrics"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/alerting"
"github.com/grafana/grafana/pkg/setting"
)
func init() {
@@ -49,11 +50,14 @@ func (this *EmailNotifier) Notify(context *alerting.EvalContext) {
cmd := &m.SendEmailCommand{
Data: map[string]interface{}{
"Title": context.GetNotificationTitle(),
"RuleState": context.Rule.State,
"RuleName": context.Rule.Name,
"Severity": context.Rule.Severity,
"RuleUrl": ruleUrl,
"Title": context.GetNotificationTitle(),
"State": context.Rule.State,
"Name": context.Rule.Name,
"Severity": context.Rule.Severity,
"SeverityColor": context.GetColor(),
"RuleUrl": ruleUrl,
"ImageLink": context.ImagePublicUrl,
"AlertPageUrl": setting.AppUrl + "alerting",
},
To: this.Addresses,
Template: "alert_notification.html",
@@ -18,6 +18,7 @@ func TestEmailIntegrationTest(t *testing.T) {
setting.Smtp.Enabled = true
setting.Smtp.TemplatesPattern = "emails/*.html"
setting.Smtp.FromAddress = "from@address.com"
setting.BuildVersion = "4.0.0"
err := Init()
So(err, ShouldBeNil)
@@ -30,19 +31,17 @@ func TestEmailIntegrationTest(t *testing.T) {
cmd := &m.SendEmailCommand{
Data: map[string]interface{}{
"Name": "Name",
"State": "Critical",
"Description": "Description",
"DashboardLink": "http://localhost:3000/dashboard/db/alerting",
"AlertPageUrl": "http://localhost:3000/alerting",
"DashboardImage": "http://localhost:3000/render/dashboard-solo/db/alerting?from=1466169458375&to=1466171258375&panelId=3&width=1000&height=500",
"TriggeredAlerts": []testTriggeredAlert{
{Name: "desktop", State: "Critical", ActualValue: 13},
{Name: "mobile", State: "Warn", ActualValue: 5},
},
"Title": "[CRITICAL] Imaginary timeserie alert",
"State": "Firing",
"Name": "Imaginary timeserie alert",
"Severity": "Critical",
"Message": "Alert message that will support markdown in some distant future.",
"RuleUrl": "http://localhost:3000/dashboard/db/graphite-dashboard",
"AlertPageUrl": "http://localhost:3000/alerting",
"ImageLink": "http://localhost:3000/render/dashboard-solo/db/graphite-dashboard?panelId=1&from=1471008499616&to=1471012099617&width=1000&height=500",
"SeverityColor": "#D63232",
},
To: []string{"asd@asd.com "},
To: []string{"asdf@asdf.com "},
Template: "alert_notification.html",
}