瀏覽代碼

Log failed tests

Brendan Abolivier 7 年之前
父節點
當前提交
0430839b01
簽署人: Brendan Abolivier <contact@brendanabolivier.com> GPG 金鑰 ID: 8EF1500759F70623
共有 1 個檔案被更改,包括 7 行新增0 行删除
  1. 7
    0
      src/metrics-alerting/alert/alert.go

+ 7
- 0
src/metrics-alerting/alert/alert.go 查看文件

@@ -6,6 +6,7 @@ import (
6 6
 	"metrics-alerting/config"
7 7
 	"metrics-alerting/script_data"
8 8
 
9
+	"github.com/sirupsen/logrus"
9 10
 	"gopkg.in/gomail.v2"
10 11
 )
11 12
 
@@ -20,6 +21,12 @@ func (a *Alerter) Alert(
20 21
 	labels map[string]string,
21 22
 	data script_data.Data,
22 23
 ) error {
24
+	alertLog := fmt.Sprintf("Test for script \"%s\" failed", script.Key)
25
+	if len(data.Key) > 0 {
26
+		alertLog = alertLog + fmt.Sprintf(" (data: %s=%s)", data.Key, data.Value)
27
+	}
28
+	logrus.Info(alertLog)
29
+
23 30
 	switch script.Action {
24 31
 	case "http":
25 32
 		return a.alertHttp(script, result, labels, data)