Browse Source

Log failed tests

Brendan Abolivier 7 years ago
parent
commit
0430839b01
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      src/metrics-alerting/alert/alert.go

+ 7
- 0
src/metrics-alerting/alert/alert.go View File

6
 	"metrics-alerting/config"
6
 	"metrics-alerting/config"
7
 	"metrics-alerting/script_data"
7
 	"metrics-alerting/script_data"
8
 
8
 
9
+	"github.com/sirupsen/logrus"
9
 	"gopkg.in/gomail.v2"
10
 	"gopkg.in/gomail.v2"
10
 )
11
 )
11
 
12
 
20
 	labels map[string]string,
21
 	labels map[string]string,
21
 	data script_data.Data,
22
 	data script_data.Data,
22
 ) error {
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
 	switch script.Action {
30
 	switch script.Action {
24
 	case "http":
31
 	case "http":
25
 		return a.alertHttp(script, result, labels, data)
32
 		return a.alertHttp(script, result, labels, data)