如何解决电子邮件警报中的换行符
发送邮件时如何打印换行符?我把它发送到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 looping\n 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 using html content in alerts annotations and using it in email template
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。