发送电子邮件时如何打印换行符?我把它发给gmail。字符n
按字面打印。我甚至尝试了</br>
标签和yaml mutliline,但都不起作用。
- alert: KubernetesPodImagePullBackOff
expr: kube_pod_container_status_waiting_reason{reason=~"ContainerCreating|CrashLoopBackOff|ErrImagePull|ImagePullBackOff"} > 0
for: 1s
labels:
severity: warning
annotations:
summary: "Kubernetes pod crash looping (instance {{ $labels.instance }}"
description: "Pod {{ $labels.pod }} is crash loopingn VALUE = {{ $value }}n LABELS: {{ $labels }}"
您需要在Alertmanager中重写电子邮件的默认模板。
你需要更换像这样的东西
{{ .Annotations.description }}
在模板中
{{ .Annotations.description | safeHtml }}
我为我自己的电子邮件模板写的,如果你没有自己的模板,你可以从https://github.com/prometheus/alertmanager/blob/master/template/default.tmpl并编辑
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
以与相同的方式
{{ .Value | safeHtml }}
另请阅读此答案prometheus在警报注释中使用html内容,并在电子邮件模板中使用