您好:
我看了您 prometheus alertmanager 的配置方法,并采用了建议先发现如下问题:
在 alertmanager.yml 配置中 告警接受定义指定html 时 发现获取不到key 值 ,配置如下: ——————————————————————————————
receivers: # 告警接收配置
- name: 'mail'
email_configs:
- to: '{{template "email.from.to" . }}' # 告警邮件发送对象
html: '{{template "email.to.html" . }}' # 告警邮件格式
send_resolved: true # 接收告警恢复邮件
————————————————————————————————
{{ define "email.from" }}xxxxxxxxx@qq.com{{ end }}
{{ define "email.to" }}xxxxxxxx@yeah.net{{ end }}
{{ define "email.to.html" }}
{{ range .Alerts }}
=========start==========<br>
告警程序: prometheus_alert <br>
告警级别: {{ .Labels.severity }} 级 <br>
告警类型: {{ .Labels.alertname }} <br>
故障主机: {{ .Labels.instance }} <br>
告警主题: {{ .Annotations.summary }} <br>
告警详情: {{ .Annotations.description }} <br>
触发时间: {{ .StartsAt.Format "2020-03-29 16:58:15" }} <br>
=========end==========<br>
{{ end }}
{{ end }}
——————————————————————————————
其中 邮件定义中 {{ define "email.to.html" }} 后并未指定值,在告警配置 html: html: '{{template "email.to.html" }}' 去掉取 . 也并未通过检测 。
希望您看到我的问题,予以解答。 谢谢!
相似问题