prometheus+grafana实现监控告警

元气满满
2026-05-13 / 0 评论 / 0 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2026年05月13日,已超过167天没有更新,若内容或图片失效,请留言反馈。

更新grafana 邮件配置

# 部署见连接: https://cloud.prd.emal.cc/index.php/archives/92/
# 在docker-compose.yaml 里面添加映射将这个配置文件里面的[smtp]启用
- ./grafana/conf/grafana.ini:/etc/grafana/grafana.ini #在docker-compose.yaml添加这样

修改文件grafana.ini
[smtp]
enabled = true
host = smtp.163.com:465   
user = demo@163.com              #改成你的邮箱
password = SDCFWRDXCGGHNJKB      #改成你的邮箱16位授权码 
skip_verify = true
from_address = demo@163.com      #改为你的邮箱
from_name = Grafana

# 完成后启动docker-compose
docker-compose down && docker-compose up -d

编辑grafana页面创建告警

27.png

{{ define "alert" }}
  {{- if gt (len .Alerts.Firing) 0 -}}{{ range .Alerts }}
  ===============================
  @告警通知
  告警程序: Grafana
  告警级别: {{ .Labels.severity }}
  告警类型: {{ .Labels.alertname }}
  故障主机: {{ .Labels.instance }}
  告警主题: {{ .Annotations.summary }}
  告警详情: {{ .Annotations.description }}
  触发时间: {{ .StartsAt.Local.Format "2006-01-02 15:04:05" }}
  静默地址: https://grafana.prd.emal.cc/alerting/list
  ===============================
  {{ end }}{{ end -}}
  {{- if gt (len .Alerts.Resolved) 0 -}}{{ range .Alerts }}
  ===============================
  @告警恢复
  告警程序: prometheus_alert
  故障主机: {{ .Labels.instance }}
  故障主题: {{ .Annotations.summary }}
  告警详情: {{ .Annotations.description }}
  告警时间: {{ .StartsAt.Local.Format "2006-01-02 15:04:05" }}
  恢复时间: {{ .EndsAt.Local.Format "2006-01-02 15:04:05" }}
  ===============================
  {{ end }}{{ end -}}
{{ end }}

28.png
26.png
29.png
31.png

  • 更多里面你可以开启静默这些操作等
    32.png
0

评论 (0)

取消