prometheus-2.36.0.linux-amd64
alertmanager-0.24.0.linux-amd64
blackbox_exporter-0.21.0.linux-amd64
grafana-8.5.4
centos 7.9
相关配置
cat alertmanager.yml
templates:
- '/opt/prometheus/alertmanager/template/default.tmpl'
cat /opt/prometheus/alertmanager/template/default.tmpl
{{ define "email.html" }}
{{- if gt (len .Alerts.Firing) 0 -}}
{{- range $index, $alert = .Alerts -}}
告警名称:{{ .Labels.alertname }}
告警级别:{{ .Labels.severity }}
告警机器:{{ .Labels.instance }} {{ .Labels.device }}
告警详情:{{ .Annotations.summary }}
告警时间:{{ (.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
{{- end }}
{{- end }}
{{- if gt (len .Alerts.Resolved) 0 -}}
{{- range $index, $alert = .Alerts -}}
告警名称:{{ .Labels.alertname }}
告警级别:{{ .Labels.severity }}
告警机器:{{ .Labels.instance }}
告警详情:{{ .Annotations.summary }}
告警时间:{{ (.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
恢复时间:{{ (.EndsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
{{- end }}
{{- end }}
{{- end }}
cat alertmanager.yml
routes:
- match:
alarm_by: send_emails
receiver: Email_alarm
receivers:
- name: Email_alarm
email_configs:- to: '3266@qq.com'
html: '{{ template "email.html" . }}'
headers: { Subject: "[服务告警,请尽快检查_GZ] 报警邮件"}
send_resolved: true
webhook_configs: - url: 'http://192.168.6.62:8080/prometheusalert?type=wx&tpl=prometheus-wx&wxurl=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=e35a-d30d-4ef8-97b7-06105761&at=ALL'
send_resolved: true
- to: '3266@qq.com'
告警信息会发到 192.168.6.62 其中8080由PrometheusAlert 提供,并转发到微信的机器人去,参考资料https://www.modb.pro/db/392087
问题,故障发生时,邮件收到的告警信息是北京时间,通过微信机器人收到的告警信息,“192.168.6.62:8080/” 是UTC时间
但微信如果不用机器人接受告警,采用agent_id 和 corp_id 接受告警,告警信息显示的又是北京时间,配置类似如下:
wechat_configs:
- send_resolved: true
to_party: '1'
agent_id: '10002'
corp_id: 'ww5d92'
api_secret: 'mJxIIMDEKC8h6fnJ-Yw'
需要解决的问题,如何设置采用微信机器人接收告警,也显示是北京时间?通过UTC+8=北京时间的办法似乎行不通,上面的告警模板已经是“StartsAt.Add 28800e9”
或者怎么给微信机器人指定告警模板,然后在模板中转换告警时间(UTC+8=北京时间),指定模板问题可以试试,但没成功,求帮助
太痛苦了,好多词汇不给输入