소스 검색

Append data to email body

Brendan Abolivier 7 년 전
부모
커밋
20f98fb409
로그인 계정: Brendan Abolivier <contact@brendanabolivier.com> GPG 키 ID: 8EF1500759F70623
1개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  1. 11
    1
      src/metrics-alerting/alert/email.go

+ 11
- 1
src/metrics-alerting/alert/email.go 파일 보기

@@ -43,7 +43,17 @@ func (a *Alerter) alertEmail(
43 43
 		if err != nil {
44 44
 			return err
45 45
 		}
46
-		body = fmt.Sprintf("%s\n\nLabels: %+v", body, string(jsonLabels))
46
+		body = fmt.Sprintf("%s\n\nLabels: %s", body, string(jsonLabels))
47
+	}
48
+
49
+	if len(data.Key) > 0 {
50
+		dataMap := make(map[string]string)
51
+		dataMap[data.Key] = data.Value
52
+		jsonData, err := json.Marshal(dataMap)
53
+		if err != nil {
54
+			return err
55
+		}
56
+		body = fmt.Sprintf("%s\n\nData: %s", body, string(jsonData))
47 57
 	}
48 58
 
49 59
 	body = fmt.Sprintf("%s\n\nScript:\n%s", body, script.Script)