-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请教一个关于企业微信的alertmanager问题 #36
Comments
可以尝试把邮件告警功能开启,看看是否能正常收到告警邮件。而且当你不配置wechat自定义模板时,alertmanager会使用默认模板,可以看看这时能否收到消息。如果这样是正常的,应该就是自定义模板的问题了,可以参考 https://godoc.org/text/template 中的语法说明自己调试下。 |
试了一下这里的模板,有语法错误: level=error ts=2019-07-18T02:11:59.582Z caller=notify.go:367 component=dispatcher msg="Error on notify" err="cancelling notify retry for "wechat" due to unrecoverable error: templating error: template: wechat.tmpl:2:11: executing "wechat.tmpl" at <len .Alerts.Firing>: error calling len: len of untyped nil" |
报错这里其实是要判断一下是否有告警或恢复信息,好为后边的迭代做预判断。我当时调试通过的软件版本如下:
我怀疑是不是后来新版本有对这里做调整。请自己debug下,问题解决了欢迎提PR |
抱歉,我并不是程序员,不太懂 |
我使用的版本如下:
alertmanager-0.18.0.linux-amd64
prometheus-2.11.1.linux-amd64
我的告警模板 wechat.tmpl 内容如下:
{{ define "wechat.tmpl" }}
{{ range .Alerts }}
========start==========
告警程序: prometheus_alert
告警级别: {{ .Labels.severity }}
告警类型: {{ .Labels.alertname }}
故障主机: {{ .Labels.instance }}
告警主题: {{ .Annotations.summary }}
告警详情: {{ .Annotations.description }}
触发时间: {{ .StartsAt.Format "2006-01-02 15:04:05" }}
========end==========
{{ end }}
{{ end }}
日志无报错
level=debug ts=2019-07-17T12:53:33.495Z caller=dispatch.go:430 component=dispatcher aggrGroup="{}:{alertname="node_status"}" msg=flushing alerts=[node_status[1a2f380][active]]
level=debug ts=2019-07-17T12:53:38.496Z caller=dispatch.go:430 component=dispatcher aggrGroup="{}:{alertname="node_status"}" msg=flushing alerts=[node_status[1a2f380][active]]
也能收到企业微信告警,但是内容为空
尝试找了别的模板,也把alertmanager降了一个版本,还是一样,可能是哪里的问题呢?
The text was updated successfully, but these errors were encountered: