alertmanager的配置说明

一、如何使用自定义配置文件

启动时指定alertmanager的配置文件

./alertmanager --config.file=alertmanager.yml 

配置项说明

<duration>:与正则表达式匹配的持续时间 [0-9]+(ms|[smhdwy])
<labelname>:与正则表达式匹配的字符串 [a-zA-Z_][a-zA-Z0-9_]*
<labelvalue>:一串unicode字符
<filepath>:当前工作目录中的有效路径
<boolean>:布尔值true或false
<string>:字符串
<secret>:密钥串,例如密码
<tmpl_string>:使用前已模板扩展的字符串
<tmpl_secret>:模板的密钥
<int>:整数值

全局配置简要说明

global:
  [ smtp_from: <tmpl_string> ]
  # 从一个模板字符串中获取相关SMTP配置,样例: smtp.example.org:587
  [ smtp_smarthost: <string> ]
  # 提供给smtp服务器的默认hostName.
  [ smtp_hello: <string> | default = "localhost" ]
  # SMTP 使用 CRAM-MD5\LOGIN\PLAIN进行身份验证. 如果为空,Alertmanager不会对SMTP服务器进行身份验证。
  [ smtp_auth_username: <string> ]
  # SMTP Auth using LOGIN and PLAIN.
  [ smtp_auth_password: <secret> ]
  # SMTP Auth using PLAIN.
  [ smtp_auth_identity: <string> ]
  # SMTP Auth using CRAM-MD5.
  [ smtp_auth_secret: <secret> ]
  # The default SMTP TLS requirement.
  # Note that Go does not support unencrypted connections to remote SMTP endpoints.
  [ smtp_require_tls: <bool> | default = true ]

  # The API URL to use for Slack notifications.
  [ slack_api_url: <secret> ]
  [ victorops_api_key: <secret> ]
  [ victorops_api_url: <string> | default = "https://alert.victorops.com/integrations/generic/20131114/alert/" ]
  [ pagerduty_url: <string> | default = "https://events.pagerduty.com/v2/enqueue" ]
  [ opsgenie_api_key: <secret> ]
  [ opsgenie_api_url: <string> | default = "https://api.opsgenie.com/" ]
  [ wechat_api_url: <string> | default = "https://qyapi.weixin.qq.com/cgi-bin/" ]
  [ wechat_api_secret: <secret> ]
  [ wechat_api_corp_id: <string> ]

  # The default HTTP client configuration
  [ http_config: <http_config> ]

  # 告警解决超时时间,超过这个时间时会被认为已解决,默认5分钟.
  [ resolve_timeout: <duration> | default = 5m ]

# 客户化模板列表
templates:
  [ - <filepath> ... ]

# 路由配置根节点
route: <route>

# 通知接收器列表
receivers:
  - <receiver> ...

# 通知抑制规则列表.
inhibit_rules:
  [ - <inhibit_rule> ... ]

二、路由配置说明

[ receiver: <string> ]
# 路由接收器名称,用于匹配接收器

# 根据标签进行告警分组。
[ group_by: '[' <labelname>, ... ']' ]

# 报警是否应该继续匹配同级节点,默认不继续匹配.
[ continue: <boolean> | default = false ]

# 使用标签匹配报警,必须包含指定标签才匹配。
match:
  [ <labelname>: <labelvalue>, ... ]

# 是否正则表达式的值来匹配标签值。
match_re:
  [ <labelname>: <regex>, ... ]

# 告警组等待时间。
[ group_wait: <duration> | default = 30s ]

# 新告警产生时,等待多久增加到已发送的告警内容中并发送。
[ group_interval: <duration> | default = 5m ]

# 重复发送告警时间间隔
[ repeat_interval: <duration> | default = 4h ]

# 特定的路由
routes:
  [ - <route> ... ]

三、接收器receiver配置说明

webhook配置说明

# 是否发送解决告警信息
[ send_resolved: <boolean> | default = true ]

# webhook地址
url: <string>

# http请求客户端配置。默认使用全局配资
[ http_config: <http_config> | default = global.http_config ]

# 最大的告警记录数,默认0表示所有数据
[ max_alerts: <int> | default = 0 ]

限制接收器告警条数
只需要配置max_alerts: int 即可,int为最大记录数。

email配置说明

# 是否发送解决信息
[ send_resolved: <boolean> | default = false ]

# 目标邮箱
to: <tmpl_string>

# 发件人邮箱,默认取全局配置.
[ from: <tmpl_string> | default = global.smtp_from ]

# The SMTP host through which emails are sent.
[ smarthost: <string> | default = global.smtp_smarthost ]

# The hostname to identify to the SMTP server.
[ hello: <string> | default = global.smtp_hello ]

# SMTP authentication information.
[ auth_username: <string> | default = global.smtp_auth_username ]
[ auth_password: <secret> | default = global.smtp_auth_password ]
[ auth_secret: <secret> | default = global.smtp_auth_secret ]
[ auth_identity: <string> | default = global.smtp_auth_identity ]

# The SMTP TLS requirement.
# Note that Go does not support unencrypted connections to remote SMTP endpoints.
[ require_tls: <bool> | default = global.smtp_require_tls ]

# TLS configuration.
tls_config:
  [ <tls_config> ]

# HTML格式的邮件模板
[ html: <tmpl_string> | default = '{{ template "email.default.html" . }}' ]
# TEXT格式的邮件模板
[ text: <tmpl_string> ]

# Further headers email header key/value pairs. Overrides any headers
# previously set by the notification implementation.
[ headers: { <string>: <tmpl_string>, ... } ]

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是一个比较复杂的问题,需要详细说明。我会尽可能地给您提供一些指导。 首先,您需要了解一些基础知识,如 Kubernetes 和 Prometheus。Kubernetes 是一个容器编排平台,可以帮助您自动管理多个容器应用程序的部署、扩展和故障恢复。Prometheus 是一个开源的监控系统,可以收集和存储应用程序的指标,并支持告警和可视化。 以下是大致的步骤: 1. 部署 Kubernetes 集群,并准备好部署 Prometheus 和 Grafana 的节点。您可以使用各种 Kubernetes 发行版,如 kops、kubeadm 等。 2. 安装和配置 Prometheus。您可以使用 Prometheus 的 Helm Chart 进行部署,并通过 Prometheus Operator 进行管理。在部署 Prometheus 时,您需要配置它来收集应用程序的指标,并将其存储在 Prometheus 存储中。 3. 部署 Grafana。您可以使用 Grafana 的 Helm Chart 进行部署,并配置它来连接到 Prometheus 存储。在 Grafana 中,您可以创建仪表板并可视化 Prometheus 存储中的指标数据。 4. 配置告警。您可以使用 Prometheus 的 Alertmanager 进行告警,并将告警发送到 Slack、Email 等渠道。在配置告警时,您需要定义告警规则,并配置 Alertmanager 来发送告警。 以上是部署 Prometheus、Grafana 和告警的大致步骤。由于每个环境的部署和配置都有所不同,所以具体的细节可能会有所不同。我建议您查阅官方文档,并根据您的需求进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值