配置
Alertmanager 的配置是通过命令行参数和配置文件进行的。命令行参数用于设置不可变系统参数,而配置文件则定义了抑制规则、通知路由和接收者。
我们可以使用可视化编辑器帮助构建路由树。
要查看所有可用的命令行参数,请运行 alertmanager -h
。
Alertmanager 可以在运行时重新加载其配置。如果新配置不正确,则不会应用更改,并会给出错误信息。通过向进程发送 SIGHUP
信号或发送到 /-/reload
端点的 HTTP POST 请求触发配置重新加载。
配置文件介绍
要指定加载哪个配置文件,请使用--config.file
标志。
./alertmanager --config.file=alertmanager.yml
该文件采用 YAML 格式编写,下文描述了此 YAML 方案(scheme)。方括号表示参数可选。对于没有在配置文件中给出的可选参数,其值设置为指定的默认值。
通用占位符定义如下:
<duration>
:匹配正则表达式((([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?|0)
的持续时间,例如1d
、1h30m
、5m
、10s
<labelname>
:匹配正则表达式[a-zA-Z_][a-zA-Z0-9_]*
的字符串<labelvalue>
:包含 Unicode 字符的字符串<filepath>
:当前工作目录中的有效路径<boolean>
:可以取值为true
或false
的布尔值<string>
:普通字符串<secret>
:作为密码等密钥的普通字符串<tmpl_string>
:在使用前进行模板展开的字符串<tmpl_secret>
:在使用前进行模板展开的密钥字符串<int>
:整数值<regex>
:有效的 RE2 正则表达式(正则表达式两端被锚定。要取消正则表达式的锚定,请使用.*<regex>.*
)
其他占位符单独指定。
这里提供了一个有效的真实情形下的示例文件。
文件布局与全局设置
全局配置指定所有其他配置上下文都有效的参数。它们还为其他配置部分提供默认值。其他顶级部分的文档也被记录在本页面中。
global: # 默认的 SMTP 发送者头部字段。 [ smtp_from: <tmpl_string> ] # 默认的 SMTP 智能主机用于发送邮件,包括端口号。通常端口号为25,或对于 TLS(有时称为 STARTTLS)的 SMTP,端口号通常为587。 # 示例:smtp.example.org:587 [ smtp_smarthost: <string> ] # 默认的主机名以标识给 SMTP 服务器。 [ smtp_hello: <string> | default = "localhost" ] # 使用 CRAM-MD5、LOGIN 和 PLAIN 的 SMTP 认证。如果为空,则 Alertmanager 不会对 SMTP 服务器进行身份验证。 [ smtp_auth_username: <string> ] # 使用 LOGIN 和 PLAIN 的 SMTP 认证。 [ smtp_auth_password: <secret> ] # 使用 LOGIN 和 PLAIN 的 SMTP 认证。 [ smtp_auth_password_file: <string> ] # 使用 PLAIN 的 SMTP 认证。 [ smtp_auth_identity: <string> ] # 使用 CRAM-MD5 的 SMTP 认证。 [ smtp_auth_secret: <secret> ] # 默认的 SMTP TLS 要求。 # 注意Go不支持到远程 SMTP 端点的未加密连接。 [ smtp_require_tls: <bool> | default = true ]
# Slack 通知使用的 API URL。 [ slack_api_url: <secret> ] [ slack_api_url_file: <filepath> ] [ victorops_api_key: <secret> ] [ victorops_api_key_file: <filepath> ] # VictorOps 默认的 API URL。 [ victorops_api_url: <string> | default = "https://alert.victorops.com/integrations/generic/20131114/alert/" ] # PagerDuty 默认 URL。 [ pagerduty_url: <string> | default = "https://events.pagerduty.com/v2/enqueue" ] [ opsgenie_api_key: <secret> ] [ opsgenie_api_key_file: <filepath> ] [ opsgenie_api_url: <string> | default = "https://api.opsgenie.com/" ] # 微信默认 API URL。 [ wechat_api_url: <string> | default = "https://qyapi.weixin.qq.com/cgi-bin/" ] [ wechat_api_secret: <secret> ] [ wechat_api_corp_id: <string> ] # Telegram 默认 API URL。 [ telegram_api_url: <string> | default = "https://api.telegram.org" ] # WebEx 默认 API URL。 [ webex_api_url: <string> | default = "https://webexapis.com/v1/messages" ] # 自定义通知模板定义文件读取的文件路径。 # 最后一个组件可以使用通配符匹配器,例如'templates/*.tmpl'。 templates: [ - <filepath> ... ]
# 路由树的根节点。route: <route>
# 通知接收者的列表。receivers: - <receiver> ...
# 抑制规则的列表。inhibit_rules: [ - <inhibit_rule> ... ]
# 已弃用:使用 time_intervals 下方。# 用于静默路由的时间间隔列表。mute_time_intervals: [ - <mute_time_interval> ... ]
# 用于静默/激活路由的时间间隔列表。time_intervals: [ - <time_interval> ... ]
Prometheus路由相关的设置
路由相关的设置允许配置告警如何根据时间进行路由、聚合、限流和静默。
路由块(Route Block)
路由块定义了路由树中的一个节点及其子节点。其可选的配置参数会从其父节点继承,如果未设置。
每个告警在配置的顶级路由处进入路由树,该路由必须匹配所有告警(即,不能有任何配置的匹配器)。然后它遍历子节点。如果continue
设置为false,则在第一个匹配的子节点之后停止。如果在匹配的节点上continue
设置为true,告警将继续与后续的兄弟节点匹配。如果告警没有匹配任何节点的子节点(没有匹配的子节点或不存在子节点),则根据当前节点的配置参数处理告警。
更多关于分组的信息,请参阅 Alertmanager。
[ receiver: <string> ]# 接收器名称,用于标识接收特定告警信息的实体。
[ group_by: '[' <labelname>, ... ']' ]# 通过哪些标签将进入的告警分组在一起。例如,多个针对 cluster=A 和 alertname=LatencyHigh 的告警会被分到一个组中。# 使用特殊值'...'作为唯一标签名来聚合所有可能的标签,例如:group_by: ['...']# 这等同于完全禁用聚合,以原样传递所有告警。除非你的上游通知系统已经执行了分组操作或者你的告警量极低,否则这不太可能是你想要的。
[ continue: <boolean> | default = false ]# 是否继续匹配后续兄弟节点的告警。
[ group_wait: <duration> | default = 30s ]# 初始等待多长时间发送通知给一组告警。允许等待抑制性告警的到来或收集同一组中的更多初始告警。# 如果省略,则子路由继承父路由的 group_wait 设置。
[ group_interval: <duration> | default = 5m ]# 在已经发送初始通知后,等待多久再发送关于新增到一组告警的通知。通常为~5分钟或更长。# 如果省略,则子路由继承父路由的 group_interval 设置。
[ repeat_interval: <duration> | default = 4h ]# 成功发送通知后,再次发送通知的等待时间。通常为~3小时或更长。# 如果省略,则子路由继承父路由的 repeat_interval 设置。# 注意,此参数受 Alertmanager 配置标志 `--data.retention` 的隐式约束。如果 repeat_interval 或数据保留期先过期,# 则会在两者之间较早发生的时刻重新发送通知。repeat_interval 应该与 group_interval 成倍数关系。
mute_time_intervals: [ - <string> ...]# 路由静默的时间段。这些必须与mute_time_intervals部分定义的时间段名称匹配。# 根据路由是否被静默,它将不会发送任何通知,但仍然正常工作(包括如果`continue`选项未设置则终止路由匹配过程)。
active_time_intervals: [ - <string> ...]# 路由活跃的时间段。这些必须与time_intervals部分定义的时间段名称匹配。# 空值表示路由始终活跃。# 路由仅在活跃时发送通知,但否则正常工作(包括如果`continue`选项未设置则终止路由匹配过程)。
[ routes: <route> ... ]# 零个或多个子路由。
示例:
# 包含所有参数的根路由器,这些参数如果子路由未进行覆盖,则会被继承。route: receiver: 'default-receiver' group_wait: 30s group_interval: 5m repeat_interval: 4h group_by: [cluster, alertname] # 所有不匹配以下子路由规则的告警将保留在根节点,并被发送到'default-receiver'。 routes: # 所有服务为 mysql 或 cassandra 的告警被发送给 'database-pager'。 - receiver: 'database-pager' group_wait: 10s matchers: - service=~"mysql|cassandra" # 所有带有 team=frontend 标签的告警匹配这个子路由。 # 它们按照产品和环境而不是集群和 alertname 进行分组。 - receiver: 'frontend-pager' group_by: [product, environment] matchers: - team="frontend"
# 所有带有 service=inhouse-service 标签的告警匹配这个子路由。 # 在非工作时间和节假日时间内,该路由将静默。 # 即使匹配了,它也会继续传递到下一个子路由。 - receiver: 'dev-pager' matchers: - service="inhouse-service" mute_time_intervals: - offhours - holidays continue: true
# 所有带有 service=inhouse-service 标签的告警匹配这个子路由。 # 该路由仅在非工作时间和节假日时间内激活。 - receiver: 'on-call-pager' matchers: - service="inhouse-service" active_time_intervals: - offhours - holidays
<time_interval>
time_interval
指定可以在路由树中引用的命名时间间隔,以在一天中的特定时间静默/激活特定路由。
name: <string>time_intervals: [ - <time_interval_spec> ... ]
<time_interval_spec>
time_interval_spec
包含时间间隔的实际定义。该语法支持以下字段:
- times: [ - <time_range> ...] weekdays: [ - <weekday_range> ...] days_of_month: [ - <days_of_month_range> ...] months: [ - <month_range> ...] years: [ - <year_range> ...] location: <string>
所有字段均为列表形式。在非空列表中,至少有一个元素满足才能匹配该字段。若字段未指定,则任何值都将匹配成功。为了匹配特定的时间间隔,所有字段都必须匹配。一些字段支持范围和负索引,下文有详细说明。
time_range
: 包含开始时间的范围(包括)并排除结束时间(不包括),以便于表示从小时边界开始/结束的时间。例如,start_time: '17:00'
和end_time: '24:00'
将从17:00开始并在24:00之前结束。其表示方式如下:
times: - start_time: HH:MM end_time: HH:MM
weekday_range
: 列出一周中的日子,一周从周日开始至周六结束。应通过名称(如 ‘Sunday’)来指定日期。为方便起见,接受的范围形式为<start_day>:<end_day>
并包含两端。例如:['monday:wednesday','saturday', 'sunday']
days_of_month_range
: 列出每月的数字日期。日期从1开始。也接受负值,从月末开始,例如,一月中的-1
代表1月31日。例如:['1:5', '-3:-1']
。超出月份起始或结束的日期将会被裁剪。例如,在二月指定['1:31']
将根据闰年调整实际结束日期为28或29天。month_range
: 使用大小写不敏感的名称(如 ‘January’)或编号(1=一月)来标识日历月份。接受范围。例如,['1:3', 'may:august', 'december']
。包含两端。year_range
: 数字列表表示年份。接受范围。例如,['2020:2022', '2030']
。包含两端。location
: 匹配 IANA 时区数据库中的位置字符串。例如,‘Australia/Sydney’。地点提供了时间间隔的时区。例如,包含在 ‘Australia/Sydney’ 地址中的时间区间可能类似于:
times: - start_time: 09:00 end_time: 17:00 weekdays: ['monday:friday']
包括周一至周五上午 9:00 至下午 5:00 之间的任何时间(使用澳大利亚悉尼当地时间)。
你还可以使用 'Local'
作为位置,以使用运行 Alertmanager 的计算机的本地时间,或使用'UTC'
作为 UTC 时间。如果未提供时区,则时间间隔采用 UTC 时间。注意:在 Windows 上,仅支持本地或 UTC,除非你使用ZONEINFO
环境变量提供自定义时区数据库。
抑制相关配置(Inhibition-related settings)
抑制功能允许根据另一组告警的存在来静默一组告警。这允许在故障期间建立系统或服务之间的依赖关系,从而只发送一组相互关联告警中最相关的告警。
更多关于抑制功能的信息,请参阅 Alertmanager。
要深入了解抑制功能以及如何在 Prometheus 中使用它,请查看 Prometheus 官方文档中的 Alertmanager 部分。这部分详细介绍了 Alertmanager 的工作原理、配置选项以及如何实现更复杂的告警处理逻辑,包括抑制功能。
<inhibit_rule>
抑制规则(inhibition rules)用于在特定条件下静默(mute)匹配的目标告警(target)。这些条件由匹配另一组匹配器的源告警(source)满足。为了应用抑制规则,目标和源告警必须在equal
列表中的标签名称上具有相同的标签值。
从语义上讲,缺失的标签与拥有空值的标签是相同的概念。因此,如果equal
列表中列出的所有标签名在源告警和目标告警中都缺失,抑制规则就会生效。
为了避免告警自抑(self-inhibition),不能让匹配目标和源规则的告警被同样目标和源规则都匹配自身(包括自身)的告警所抑制。然而,我们建议在选择目标和源匹配器时,要确保告警永远不会同时匹配两侧的匹配器,这样推理起来更简单,同时也不会触发自抑这种特殊情况。
# 已废弃:请使用下方的 target_matchers。# 需要在告警被抑制前满足的匹配器。target_match: [ <labelname>: <labelvalue>, ... ]
# 已废弃:请使用下方的 target_matchers。target_match_re: [ <labelname>: <regex>, ... ]
# 一个包含需要满足以使目标告警被抑制的匹配器列表。target_matchers: [ - <matcher> ... ]
# 已废弃:请使用下方的 source_matchers。# 至少有一个告警存在时,抑制才会生效的匹配器。source_match: [ <labelname>: <labelvalue>, ... ]
# 已废弃:请使用下方的 source_matchers。source_match_re: [ <labelname>: <regex>, ... ]
# 包含需要在源和目标告警中具有相同值的匹配器列表,# 以便抑制效果生效。[ equal: '[' <labelname>, ... ']' ]
标签匹配器(Label Matchers)
标签匹配器用于将告警与路由、静默规则和抑制规则相匹配。
重要提示:Prometheus 正在增加对标签和指标中的 UTF-8 支持。为了支持 Alertmanager 的 UTF-8,从版本 0.27 开始,Alertmanager 提供了一个新的解析器,该解析器包含了一系列不向后兼容的变化。大多数匹配器将向前兼容,但有些不会。Alertmanager 正在执行一个过渡期,在此期间它同时支持 UTF-8 和经典匹配器,并提供了一些工具帮助你准备过渡。
如果这是新的 Alertmanager 安装,推荐在创建 Alertmanager 配置文件之前启用 UTF-8 严格模式。你可以在这里找到如何启用 UTF-8 严格模式的说明。
如果这是现有的 Alertmanager 安装,请推荐在启用 UTF-8 严格模式之前,先以默认模式(称为回退模式)运行 Alertmanager。在这种模式下,Alertmanager 如果需要你在启用 UTF-8 严格模式之前修改配置文件,会记录告警信息。在接下来的两个版本中,Alertmanager 将使 UTF-8 严格模式成为默认设置,因此尽快过渡非常重要。
无论 Alertmanager 安装是新安装还是现有安装,你也可以使用amtool
来验证 Alertmanager 配置文件是否与 UTF-8 严格模式兼容,再在 Alertmanager 服务器中启用它。你无需运行 Alertmanager 服务器即可进行此操作。你可以在这里找到如何使用 amtool
验证 Alertmanager 配置文件的说明。
Prometheus Alertmanager 服务器运行模式
在过渡期期间,Alertmanager 支持三种运行模式,分别是回退模式、UTF-8 严格模式和经典模式。默认模式是回退模式。
Alertmanager 服务器的运维人员应该在过渡期结束前迁移到 UTF-8 严格模式。Alertmanager 在接下来的两个版本中将使 UTF-8 严格模式成为默认设置,因此尽快迁移非常重要。
回退模式(Fallback Mode)
Alertmanager 以一种称为回退模式的特殊模式作为其默认模式运行。作为使用者,你不会在路由、静默或禁止规则的工作方式体验到任何差异。
在回退模式下,配置首先被解析为 UTF-8 匹配器,如果与 UTF-8 解析器不兼容,则被解析为经典匹配器。如果你的 Alertmanager 配置包含与 UTF-8 解析器不兼容的匹配器,Alertmanager 会将它们解析为经典匹配器并记录告警。此告警还包括有关如何将匹配器从经典匹配器更改为 UTF-8 匹配器的建议。例如:
ts=2024-02-11T10:00:00Z caller=parse.go:176 level=warn msg=“Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the classic matchers parser as a fallback. To make this input compatible with the UTF-8 matchers parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.” input=“foo=” origin=config err=“end of input: expected label value” suggestion=“foo="""
这里,通过双引号表达式的右侧给出 foo=""
,可以将匹配器 foo=
变成有效的 UTF-8 匹配器。这两个匹配器是等效的,但是对于 UTF-8 匹配器,匹配器的右侧是必填字段。
在极少数情况下,配置可能会导致 UTF-8 和经典解析器之间出现不一致。当匹配器在两个解析器中都有效时,由于增加了对 UTF-8 的支持,就会发生这种情况,因此根据使用的解析器会导致不同的解析。如果你的 Alertmanager 配置不一致,Alertmanager 将使用经典解析器并记录告警。例如:
ts=2024-02-11T10:00:00Z caller=parse.go:183 level=warn msg=“Matchers input has disagreement” input=“qux=“\xf0\x9f\x99\x82”\n” origin=config
在遇到任何分歧时,应该根据具体情况分析。取决于分歧的本质,启用严格UTF-8模式之前可能无需更新配置。例如,\xf0\x9f\x99\x82
是😊 emoji 的字节序列。如果你是想匹配一个确切的😊 emoji,则无需进行更改。然而,如果你的意图是匹配确切的\xf0\x9f\x99\x82
字节序列,则匹配器应更改为qux="\xf0\x9f\x99\x82"
。
UTF-8 严格模式(UTF-8 strict mode)
在严格 UTF-8 模式下,Alertmanager 禁用了经典匹配器的支持:
alertmanager —config.file=config.yml —enable-feature=“utf8-strict-mode”
此模式应适用于新安装的 Alertmanager,以及在解决所有不兼容匹配器告警后,现有 Alertmanager 安装。在解决所有不兼容匹配器的告警之前,Alertmanager 不会以严格 UTF-8 模式启动:
ts=2024-02-11T10:00:00Z caller=coordinator.go:118 level=error component=configuration msg=“Loading configuration file failed” file=config.yml err=“end of input: expected label value”
在过渡期结束后,严格 UTF-8 模式将成为 Alertmanager 的默认模式。
经典模式(Classic mode)
经典模式相当于 Alertmanager 版本0.26.0及更早版本:
alertmanager --config.file=config.yml --enable-feature="classic-mode"
如果你怀疑回退模式或 UTF-8 严格模式存在问题,可以使用此模式。如果你在使用过程中,请在 GitHub 上提出 issue 并提供尽可能多的信息。
验证(Verification)
你可以使用amtool
在启用 Alertmanager 服务器之前验证 Alertmanager 配置文件是否与 UTF-8 严格模式兼容。无需运行 Alertmanager 服务器即可进行此操作。
与 Alertmanager 服务器一样,如果配置不兼容或存在冲突,amtool
将给出 warning 信息:
amtool check-config config.ymlChecking 'config.yml'level=warn msg="Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the classic matchers parser as a fallback. To make this input compatible with the UTF-8 matchers parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue." input="foo=" origin=config err="end of input: expected label value" suggestion="foo=\"\""level=warn msg="Matchers input has disagreement" input="qux=\"\\xf0\\x9f\\x99\\x82\"\n" origin=config SUCCESSFound: - global config - route - 2 inhibit rules - 2 receivers - 0 templates
只有当amtool
中没有给出 warning 时,你才能知道配置是否与 UTF-8 严格模式兼容:
amtool check-config config.ymlChecking 'config.yml' SUCCESSFound: - global config - route - 2 inhibit rules - 2 receivers - 0 templates
你还可以使用amtool
在 UTF-8 严格模式下作为额外的验证级别。如果命令将会执行失败,则说明配置有误:
amtool check-config config.yml --enable-feature="utf8-strict-mode"level=warn msg="UTF-8 mode enabled"Checking 'config.yml' FAILED: end of input: expected label value
amtool: error: failed to validate 1 file(s)
如果命令成功执行,配置即生效:
amtool check-config config.yml --enable-feature="utf8-strict-mode"level=warn msg="UTF-8 mode enabled"Checking 'config.yml' SUCCESSFound: - global config - route - 2 inhibit rules - 2 receivers - 0 templates
UTF-8 匹配器(UTF-8 matchers)
UTF-8 匹配器由三个标记组成:
- 未被引号的字面量或双引号字符串,用于标签名称。
- 其中之一:
=
,!=
,=~
或!~
。=
表示等于,!=
表示不等于,=~
表示匹配正则表达式,而!~
表示不匹配正则表达式。 - 未被引号包围的字面量或双引号字符串,用于正则表达式或标签值。
未被引号(unquoted)的字面量可以包含所有非保留字符的UTF-8字符。这些是空格以及{ } ! = ~ , \ " '
中的所有字符。例如,foo
、[a-zA-Z]+
和Προμηθεύς
(希腊语中的 Prometheus )都是有效的未被引号字面量示例。然而,foo!
不是一个有效的字面量,因为!
是一个保留字符。
双引号字符串可以包含所有 UTF-8 字符。与未被引号的字面量不同,双引号字符串可以使用保留字符。你甚至可以使用 UTF-8 代码点。例如,"foo!"
、"bar,baz"
、"baz qux"
和 "<font style="color:rgb(51, 51, 51);background-color:rgb(249, 242, 244);">\xf0\x9f\x99\x82</font>"
都是有效的双引号字符串。
经典匹配器
经典匹配器是一个字符串,其语法受到 PromQL 和 OpenMetrics 的影响。经典匹配器的语法由三个标记组成:
- 有效 Prometheus 标签名。
- 其中之一:
=
,!=
,=~
或!~
。=
表示等于,!=
表示字符串不相等,=~
用于正则表达式的相等比较,而!~
用于正则表达式的不相等比较。它们在 PromQL 选择器中具有相同的意义。 - UTF-8 字符串,可能被双引号包围。每个标记前后可以有任意数量的空白字符。
- 第三部分可能是空字符串。在第三部分内部,OpenMetrics 转义规则适用:“表示双引号,\表示换行符,\表示原样反斜杠。未转义的
"
不能再第三部分内部出现(只能作为首尾字符)。但是,未跟在\
、n
或"
后面的换行符字符以及单个\
字符是可以接受的,在这种情况下,它们会作为原始反斜杠被处理。
匹配器的组合
你可以组合匹配器以创建复杂的匹配表达式。当组合时,只有所有匹配器都匹配,整个表达式才能匹配。例如,表达式 {alertname="Watchdog", severity=~"warning|critical"}
将匹配带有标签alertname=Watchdog
、severity=critical
的告警,但不会匹配带有标签alertname=Watchdog
、severity=none
的告警,因为虽然alertname
为Watchdog
,但severity
既不是warning
也不是critical
。
你可以使用YAML列表将匹配器组合成表达式:
- alertname="Watchdog"- severity=~"warning|critical"
或者使用受形似 PromQL 的表达式,其中每个匹配器以逗号分隔:
{alertname="Watchdog", severity=~"warning|critical"}
可以在末尾使用一个逗号:
{alertname="Watchdog", severity=~"warning|critical",}
大括号{}
是可选的,
alertname="Watchdog", severity=~"warning|critical"
然而,不能有不完整的左大括号或右大括号:
{alertname="Watchdog", severity=~"warning|critical"
alertname="Watchdog", severity=~"warning|critical"}
你也不能重复左右两个大括号:
{{alertname="Watchdog", severity=~"warning|critical",}}
双引号外允许有空格(空格、制表符和换行符),并且对匹配器本身没有影响。例如:
{ alertname = "Watchdog", severity =~ "warning|critical",}
等同于
{alertname="Watchdog",severity=~"warning|critical"}
更多例子
- 两个相等的匹配器可以以以下 YAML 列表表示
matchers: - foo = bar - dings != bums
- 也可以以以下缩短形式表示
matchers: [ foo = bar, dings != bums ]
如下所示,在短格式中,最好使用双引号以避免逗号等特殊字符的问题:
matchers: [ "foo = \"bar,baz\"", "dings != bums" ]
- 你还可以将两个匹配器放入一个类似 PromQL 的字符串中。单引号在这里效果最好:
matchers: [ '{foo="bar", dings!="bums"}' ]
- 为了避免 YAML 中的转义和引用规则出现问题,你还可以使用 YAML 块:
matchers: - | {quote=~"She said: \"Hi, all!( How're you…)?\""}
通用接收器(receiver)相关配置
这些接收器配置项允许你为基于 HTTP 的接收器配置通知目标(接收器)和 HTTP 客户端选项。
接收器是一个或多个通知集成的有名配置。
注意:为了解除过去对新接收器的停用行为,大家一致认为,除了现有的要求之外,新的通知集成还需要有一个具有推送访问权限的专门维护人员。
# 接收器的唯一性名称。name: <string>
# 若干个通知集成的配置。discord_configs: [ - <discord_config>, ... ]email_configs: [ - <email_config>, ... ]msteams_configs: [ - <msteams_config>, ... ]opsgenie_configs: [ - <opsgenie_config>, ... ]pagerduty_configs: [ - <pagerduty_config>, ... ]pushover_configs: [ - <pushover_config>, ... ]slack_configs: [ - <slack_config>, ... ]sns_configs: [ - <sns_config>, ... ]telegram_configs: [ - <telegram_config>, ... ]victorops_configs: [ - <victorops_config>, ... ]webex_configs: [ - <webex_config>, ... ]webhook_configs: [ - <webhook_config>, ... ]wechat_configs: [ - <wechat_config>, ... ]
<http_config>
http_config
配置接收方用于与基于 HTTP 的 API 服务进行通信的 HTTP 客户端。
# 注意,`basic_auth` 和 `authorization` 选项是互斥的。
# 使用配置的用户名和密码设置 `Authorization` 头部。# `password` 和 `password_file` 是互斥的。basic_auth: [ username: <string> ] # 用户名 [ password: <secret> ] # 密码(加密存储) [ password_file: <string>] # 密码文件路径
# 为 `Authorization` 头部配置可选参数。authorization: # 设置认证类型。 [ type: <string> | 默认值: Bearer ] # 设置凭证信息。与 `credentials_file` 互斥。 [ credentials: <secret> ] # 凭证信息(加密存储) # 使用从配置文件中读取的凭证信息设置凭证。与 `credentials` 互斥。 [ credentials_file: <filename> ] # 凭证文件路径
# 可选的 OAuth 2.0 配置。# 不能同时使用于 `basic_auth` 或 `authorization`。oauth2: [ <oauth2> ] # OAuth 2.0 配置项
# 是否启用 HTTP2。[ enable_http2: <bool> | 默认值: 真 ]
# 可选代理 URL。[ proxy_url: <string> ] # 代理服务器地址# 包含 IP 地址、CIDR 表示法或域名的逗号分隔字符串,这些应该被排除在代理之外。IP 地址和域名可以包含端口号。[ no_proxy: <string> ] # 排除代理的列表# 通过环境变量(HTTP_PROXY, http_proxy, HTTPS_PROXY, https_proxy, NO_PROXY, no_proxy)指定代理 URL。[ proxy_from_environment: <boolean> | 默认值: 假 ]# 指定在 CONNECT 请求期间发送给代理的头部。[ proxy_connect_header: [ <string>: [<secret>, ...] ] # 头部名称和其对应的值(可能加密)
# 配置是否遵循 HTTP 3xx 重定向。[ follow_redirects: <bool> | 默认值: 真 ]
# 配置 TLS 设置。tls_config: [ <tls_config> ] # TLS 配置项
使用客户端身份凭据授权类型的 OAuth 2.0 身份验证。 Alertmanager 使用指定的客户端访问权限和密钥从指定端点获取访问令牌。
client_id: <string>[ client_secret: <secret> ]
# 从文件中读取客户端密钥。与`client_secret`互斥。[ client_secret_file: <filename> ]
# 请求令牌时的权限范围。scopes: [ - <string> ... ]
# 用于获取令牌的 URL。token_url: <string>
# 可选的附加到令牌 URL 的参数。endpoint_params: [ <string>: <string> ... ]
# 配置令牌请求的 TLS 设置。tls_config: [ <tls_config> ]
# 可选代理URL。[ proxy_url: <string> ]# 包含 IP、CIDR 表示法、域名的逗号分隔字符串,这些应该被排除在代理之外。IP和域名可以包含端口号。[ no_proxy: <string> ]# 使用通过环境变量(HTTP_PROXY, https_proxy, HTTPs_PROXY, https_proxy, 和 no_proxy)指示的代理URL。[ proxy_from_environment: <boolean> | 默认值: false ]# 指定在 CONNECT 请求期间发送给代理的头部。[ proxy_connect_header: [ <string>: [<secret>, ...] ] ]
<tls_config>
tls_config
配置 TLS 连接。
# CA 证书,用于验证服务器证书。[ ca_file: <filepath> ]
# 客户端认证到服务器所需的证书和密钥文件。[ cert_file: <filepath> ][ key_file: <filepath> ]
# ServerName 扩展,用于指示服务器名称。# 参阅:http://tools.ietf.org/html/rfc4366#section-3.1[ server_name: <string> ]
# 禁用对服务器证书的验证。[ insecure_skip_verify: <boolean> | 默认值 = false]
# 最低可接受的 TLS 版本。接受的值:TLS10(TLS 1.0)、TLS11(TLS 1.1)、TLS12(TLS 1.2)、TLS13(TLS 1.3)。# 如果未设置,则 Prometheus 将使用 Go 默认的最低版本,即 TLS 1.2。# 查看 https://pkg.go.dev/crypto/tls#Config 中的MinVersion。[ min_version: <string> ]# 最高可接受的 TLS 版本。接受的值:TLS10(TLS 1.0)、TLS11(TLS 1.1)、TLS12(TLS 1.2)、TLS13(TLS 1.3)。# 如果未设置,则 Prometheus 将使用 Go 默认的最大版本,即TLS 1.3。# 查看 https://pkg.go.dev/crypto/tls#Config 中的 MaxVersion。[ max_version: <string> ]
集成接收器配置
<discord_config>
Discord 通知通过 Discord webhook API 发送。请参阅 Discord 的 Webhooks 简介文章,了解如何为频道(channel)配置 Webhook 集成。
# 是否通知已解决告警。[ send_resolved: <boolean> | default = false ]
# Discord webhook 地址。# webhook_url 和 webhook_url_file 互斥。webhook_url: <secret>webhook_url_file: <filepath>
# 消息标题模板。[ title: <tmpl_string> | default = '{{ template "discord.default.title" . }}' ]
# 消息正文模板。[ message: <tmpl_string> | default = '{{ template "discord.default.message" . }}' ]
# HTTP 客户端配置。[ http_config: <http_config> | default = global.http_config ]
<email_config>
# 是否通知已解决告警。[ send_resolved: <boolean> | default = false ]
# 发送通知的电子邮件地址。to: <tmpl_string>
# 发件人的地址。[ from: <tmpl_string> | default = global.smtp_from ]
# 通过该 SMTP 服务器发送电子邮件的主机名。[ smarthost: <string> | default = global.smtp_smarthost ]
# 识别 SMTP 服务器的主机名。[ hello: <string> | default = global.smtp_hello ]
# SMTP 认证信息。# 注意:auth_password 和 auth_password_file 互斥。[ auth_username: <string> | default = global.smtp_auth_username ][ auth_password: <secret> | default = global.smtp_auth_password ][ auth_password_file: <string> | default = global.smtp_auth_password_file ][ auth_secret: <secret> | default = global.smtp_auth_secret ][ auth_identity: <string> | default = global.smtp_auth_identity ]
# SMTP 的 TLS 要求。# 注意,Go 不支持与远程 SMTP 端点的未加密连接。[ require_tls: <bool> | default = global.smtp_require_tls ]
# TLS 配置.tls_config: [ <tls_config> ]
# 电子邮件通知的 HTML 正文。[ html: <tmpl_string> | default = '{{ template "email.default.html" . }}' ]# 电子邮件通知的文本正文。[ text: <tmpl_string> ]
# 电子邮件头部键/值对。覆盖由通知实现之前设置的任何头部。[ headers: { <string>: <tmpl_string>, ... } ]
<msteams_config>
Microsoft Teams 通知通过传入 Webhooks API 端点发送。
# 是否在告警解决时通知。[ send_resolved: <boolean> | default = true ]
# 入站 webhook 地址。# webhook_url 和 webhook_url_file 不能同时使用。[ webhook_url: <secret> ][ webhook_url_file: <filepath> ]
# 消息标题模板。[ title: <tmpl_string> | default = '{{ template "msteams.default.title" . }}' ]
# 消息摘要模板。[ summary: <tmpl_string> | default = '{{ template "msteams.default.summary" . }}' ]
# 消息正文模板。[ text: <tmpl_string> | default = '{{ template "msteams.default.text" . }}' ]
# HTTP 客户端配置。[ http_config: <http_config> | default = global.http_config ]
<opsgenie_config>
OpsGenie 通知通过 OpsGenie API 发送。
# 是否通知已解决的告警。[ send_resolved: <boolean> | default = true ]
# 当与OpsGenie API通信时使用的API密钥。[ api_key: <secret> | default = global.opsgenie_api_key ]
# 当与OpsGenie API通信时使用的API密钥文件路径。与api_key冲突。[ api_key_file: <filepath> | default = global.opsgenie_api_key_file ]
# 向OpsGenie API发送请求的主机。[ api_url: <string> | default = global.opsgenie_api_url ]
# 限制为130个字符的告警文本。[ message: <tmpl_string> | default = '{{ template "opsgenie.default.message" . }}' ]
# 告警的描述。[ description: <tmpl_string> | default = '{{ template "opsgenie.default.description" . }}' ]
# 指向通知发件人的反向链接。[ source: <tmpl_string> | default = '{{ template "opsgenie.default.source" . }}' ]
# 提供有关告警的详细信息的链接。# 默认情况下,所有常用标签都会作为详细信息包含在内。[ details: { <string>: <tmpl_string>, ... } ]
# 负责通知的告警响应者列表。responders: [ - <responder> ... ]
# 附加到通知的标签的逗号分隔列表。[ tags: <tmpl_string> ]
# 告警的额外说明。[ note: <tmpl_string> ]
# 告警的优先级级别。可能的值是 P1、P2、P3、P4 和 P5。[ priority: <tmpl_string> ]
# 是否在 OpsGenie 中更新已存在的告警的消息和描述。# 默认情况下,告警永远不会在OpsGenie中更新,新消息仅出现在活动日志中。[ update_alerts: <boolean> | default = false ]
# 可用于指定告警相关的域的可选字段。[ entity: <tmpl_string> ]
# 附加到告警的可操作动作的逗号分隔列表。[ actions: <tmpl_string> ]
# HTTP 客户端的配置。[ http_config: <http_config> | default = global.http_config ]
# 这些字段中恰好应该定义一个。[ id: <tmpl_string> ][ name: <tmpl_string> ][ username: <tmpl_string> ]
# "团队"、"团队"、"用户"、"递送"或"时间表"。type: <tmpl_string>
<pagerduty_config>
PagerDuty 通知通过 PagerDuty API 发送。 PagerDuty 提供了有关如何与 Prometheus 进行集成的文档。在使用 <pagerduty_config>
时,Alertmanager v0.27 与 Alertmanager 的 v0.11 存在较大差异,并且提供了更多对 PagerDuty 的 Events API v2 的支持。
# 是否通知已解决的告警。[ send_resolved: <boolean> | default = true ]
# 路由和服务键互斥。# 当使用PagerDuty集成类型为“事件APIv2”时的PagerDuty集成密钥。# 它与`routing_key_file`互斥。routing_key: <tmpl_secret># 从文件读取 Pager Duty 路由密钥。# 它与`routing_key`互斥。routing_key_file: <filepath># 当使用 PagerDuty 集成类型为 “Prometheus” 时的 PagerDuty 集成密钥。# 它与 `service_key_file` 互斥。service_key: <tmpl_secret># 从文件读取 Pager Duty 服务密钥。# 它与 `service_key` 互斥。service_key_file: <filepath>
# 发送 API 请求的 URL。[ url: <string> | default = global.pagerduty_url ]
# Alertmanager 的客户端标识。[ client: <tmpl_string> | default = '{{ template "pagerduty.default.client" . }}' ]# 通知发送者的链接。[ client_url: <tmpl_string> | default = '{{ template "pagerduty.default.clientURL" . }}' ]
# 事故的描述。[ description: <tmpl_string> | default = '{{ template "pagerduty.default.description" .}}' ]
# 事故的严重性。[ severity: <tmpl_string> | default = 'error' ]
# 受影响系统的唯一性位置。[ source: <tmpl_string> | default = client ]
# 提供有关事故的进一步详细信息的任意键/值对的集合。[ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}'} ]
# 附加到事故的图片。images: [ <image_config> ... ]
# 附加到事故的链接。links: [ <link_config> ... ]
# 受影响系统的损坏部分或组件。[ component: <tmpl_string> ]
# 受影响系统的集群或来源组。[ group: <tmpl_string> ]
# 事件的类/类型。[ class: <tmpl_string> ]
# HTTP客户端的配置。[ http_config: <http_config> | default = global.http_config ]
<image_config>
这些字段记录在 PagerDuty API 文档中。
href: <tmpl_string>src: <tmpl_string>alt: <tmpl_string>
<link_config>
这些字段记录在 PagerDuty API 文档中。
href: <tmpl_string>text: <tmpl_string>
<pushover_config>
Pushover 通知通过 Pushover API 发送。
# 是否通知已解决告警。[ send_resolved: <boolean> | default = true ]
# 接收者的用户密钥。# user_key 和 user_key_file 是互斥的。user_key: <secret>user_key_file: <filepath>
# 注册的应用程序的 API 令牌,参见 https://pushover.net/apps# 你也可以通过克隆此 Prometheus 应用注册令牌:# https://pushover.net/apps/clone/prometheus# token 和 token_file 是互斥的。token: <secret>token_file: <filepath>
# 通知标题。[ title: <tmpl_string> | default = '{{ template "pushover.default.title" . }}' ]
# 通知消息。[ message: <tmpl_string> | default = '{{ template "pushover.default.message" . }}' ]
# 显示在消息旁边的补充 URL。[ url: <tmpl_string> | default = '{{ template "pushover.default.url" . }}' ]
# 可选设备发送通知,参见 https://pushover.net/api#device[ device: <string> ]
# 可选的通知声音,参见 https://pushover.net/api#sound[ sound: <string> ]
# 优先级,参见 https://pushover.net/api#priority[ priority: <tmpl_string> | default = '{{ if eq .Status "firing" }}2{{ else }}0{{ end }}' ]
# Pushover 服务器将为用户发送同一通知的频率。# 必须至少为30秒。[ retry: <duration> | default = 1m ]
# 通知将被重新尝试的时间长度,除非用户确认了通知。[ expire: <duration> | default = 1h ]
# 可选的通知存活时间(TTL),参见 https://pushover.net/api#ttl[ ttl: <duration> ]
# HTTP客户端的配置。[ http_config: <http_config> | default = global.http_config ]
<slack_config>
Slack 通知可以通过 Incoming Webhooks 或 Bot Tokens 发送。
如果使用 Incoming Webhooks,则需要设置 api_url
为接收 Webhooks 的 URL,或者写入在 api_url_file
中引用的文件。
如果使用 Bot Tokens,则必须将 api_url
设置为 https://slack.com/api/chat.postMessage
,在 http_config
中设置 Bot Token 作为认证凭据,并在 channel
中包含要发送通知的频道名称或频道 ID。如果使用频道名称,可以省略 #
符号。
通知包含一个附件。
# 是否通知已解决告警。[ send_resolved: <boolean> | default = false ]
# Slack webhook URL。api_url 或 api_url_file 应该设置。如果此处未设置,则默认为全局设置。[ api_url: <secret> | default = global.slack_api_url ][ api_url_file: <filepath> | default = global.slack_api_url_file ]
# 发送通知的目标频道或用户。channel: <tmpl_string>
# 根据 Slack webhook API 定义的 API 请求数据。[ icon_emoji: <tmpl_string> ][ icon_url: <tmpl_string> ][ link_names: <boolean> | default = false ][ username: <tmpl_string> | default = '{{ template "slack.default.username" . }}' ]# 下面的参数定义了附件。actions: [ <action_config> ... ][ callback_id: <tmpl_string> | default = '{{ template "slack.default.callbackid" . }}' ][ color: <tmpl_string> | default = '{{ if eq .Status "firing" }}danger{{ else }}good{{ end }}' ][ fallback: <tmpl_string> | default = '{{ template "slack.default.fallback" . }}' ]fields: [ <field_config> ... ][ footer: <tmpl_string> | default = '{{ template "slack.default.footer" . }}' ][ mrkdwn_in: '[' <string>, ... ']' | default = ["fallback", "pretext", "text"] ][ pretext: <tmpl_string> | default = '{{ template "slack.default.pretext" . }}' ][ short_fields: <boolean> | default = false ][ text: <tmpl_string> | default = '{{ template "slack.default.text" . }}' ][ title: <tmpl_string> | default = '{{ template "slack.default.title" . }}' ][ title_link: <tmpl_string> | default = '{{ template "slack.default.titlelink" . }}' ][ image_url: <tmpl_string> ][ thumb_url: <tmpl_string> ]
# HTTP 客户端的配置。[ http_config: <http_config> | default = global.http_config ]
<action_config>
有关信息附件和交互式信息的 Slack API 文档中记录了这些字段。
text: <tmpl_string>type: <tmpl_string># url name value 必须至少给出一个[ url: <tmpl_string> ][ name: <tmpl_string> ][ value: <tmpl_string> ]
[ confirm: <action_confirm_field_config> ][ style: <tmpl_string> | default = '' ]
<action_confirm_field_config>
这些字段记录在 Slack API 文档中。
text: <tmpl_string>[ dismiss_text: <tmpl_string> | default '' ][ ok_text: <tmpl_string> | default '' ][ title: <tmpl_string> | default '' ]
<field_config>
这些字段记录在 Slack API 文档中。
title: <tmpl_string>value: <tmpl_string>[ short: <boolean> | default = slack_config.short_fields ]
<sns_config>
# 是否通知已解决告警。[ send_resolved: <boolean> | default = true ]
# AWS SNS API 的 URL,例如:https://sns.us-east-2.amazonaws.com。# 如果未指定,则会使用 SNS SDK 中的 SNS API URL。[ api_url: <tmpl_string> ]
# 配置 AWS 的 Signature Verification 4 签名流程来签名请求。sigv4: [ <sigv4_config> ]
# AWS SNS 主题 ARN,例如:arn:aws:sns:us-east-2:698519295917:My-Topic# 如果不指定此值,则必须指定电话号码或目标 ARN。# 如果使用 FIFO SNS 主题,请设置消息组间隔超过 5 分钟# 以防具有相同分组键的消息被 SNS 默认去重窗口重复[ topic_arn: <tmpl_string> ]
# 当消息传递到电子邮件端点时的主题行。[ subject: <tmpl_string> | default = '{{ template "sns.default.subject" .}}' ]
# 通过 E.164 格式以 SMS 方式传递消息的电话号码。# 如果不指定此值,则必须指定主题 ARN 或电话号码。[ phone_number: <tmpl_string> ]
# 如果通过移动通知传递消息的移动平台端点 ARN。# 如果不指定此值,则必须指定主题 ARN 或电话号码。[ target_arn: <tmpl_string> ]
# SNS 通知的消息内容。[ message: <tmpl_string> | default = '{{ template "sns.default.message" .}}' ]
# SNS 消息属性。attributes: [ <string>: <string> ... ]
# HTTP 客户端的配置。[ http_config: <http_config> | default = global.http_config ]
<sigv4_config>
# AWS 区域。如果空白,则使用默认凭据链中的区域。[ region: <string> ]
# AWS API 密钥。必须同时提供访问密钥和秘密密钥,或者两者都为空。# 如果为空,则会使用环境变量 `AWS_ACCESS_KEY_ID` 和 `AWS_SECRET_ACCESS_KEY`。[ access_key: <string> ][ secret_key: <secret> ]
# 使用指定的 AWS 个人资料进行身份验证。[ profile: <string> ]
# AWS 角色 ARN,作为使用 AWS API 密钥的替代方案。[ role_arn: <string> ]
<telegram_config>
# 是否通知已解决告警。[ send_resolved: <boolean> | default = true ]
# Telegram API 的 URL,例如:https://api.telegram.org。# 如果未指定,则将使用默认 API URL。[ api_url: <string> | default = global.telegram_api_url ]
# Telegram 机器人令牌。它与 `bot_token_file` 相互排斥。[ bot_token: <secret> ]
# 从文件中读取 Telegram 机器人令牌。它与 `bot_token` 相互排斥。[ bot_token_file: <filepath> ]
# 发送消息的聊天 ID。[ chat_id: <int> ]
# 消息模板。[ message: <tmpl_string> default = '{{ template "telegram.default.message" .}}' ]
# 禁用 Telegram 通知[ disable_notifications: <boolean> | default = false ]
# Telegram 消息的解析模式,支持的值是 MarkdownV2、Markdown、HTML 和空字符串(纯文本)。[ parse_mode: <string> | default = "HTML" ]
# HTTP 客户端的配置。[ http_config: <http_config> | default = global.http_config ]
<victorops_config>
VictorOps 通知通过 VictorOps API 发送。
# 是否需要通知已解决的告警。[ send_resolved: <boolean> | default = true ]
# 当与 VictorOps API 通信时使用的 API 密钥。# 它与 `api_key_file` 相互排斥。[ api_key: <secret> | default = global.victorops_api_key ]
# 从文件中读取用于与 VictorOps API 通信的 API 密钥。# 它与 `api_key` 相互排斥。[ api_key_file: <filepath> | default = global.victorops_api_key_file ]
# VictorOps API 的 URL。[ api_url: <string> | default = global.victorops_api_url ]
# 用于将告警映射到团队的关键字。routing_key: <tmpl_string>
# 描述告警的行为(CRITICAL、WARNING、INFO)。[ message_type: <tmpl_string> | default = 'CRITICAL' ]
# 告警问题的摘要。[ entity_display_name: <tmpl_string> | default = '{{ template "victorops.default.entity_display_name" . }}' ]
# 告警问题的详细解释。[ state_message: <tmpl_string> | default = '{{ template "victorops.default.state_message" . }}' ]
# 来自监控工具的状态消息。[ monitoring_tool: <tmpl_string> | default = '{{ template "victorops.default.monitoring_tool" . }}' ]
# HTTP 客户端的配置。[ http_config: <http_config> | default = global.http_config ]
<webhook_config>
Webhook 接收器可以用于配置通用接收器。
# 是否需要通知已解决的告警。[ send_resolved: <boolean> | default = true ]
# 发送 HTTP POST 请求的目标端点。# url 和 url_file 相互排斥。url: <secret>url_file: <filepath>
# HTTP 客户端的配置。[ http_config: <http_config> | default = global.http_config ]
# 单个 webhook 消息包含的告警的最大数量。超过此阈值的告警将被截断。当将其留为默认值 0 时,所有告警都将包含在内。[ max_alerts: <int> | default = 0 ]
Alertmanager 将以以下 JSON 格式向配置好的 HTTP 端点发送 HTTP POST 请求:
{ "version": "4", "groupKey": <string>, // 识别告警组的键(例如,重复数据删除) "truncatedAlerts": <int>, // 有多少告警因 “max_alerts” 而被截断 "status": "<resolved|firing>", "receiver": <string>, "groupLabels": <object>, "commonLabels": <object>, "commonAnnotations": <object>, "externalURL": <string>, // Alertmanager 的回链。 "alerts": [ { "status": "<resolved|firing>", "labels": <object>, "annotations": <object>, "startsAt": "<rfc3339>", "endsAt": "<rfc3339>", "generatorURL": <string>, // 标识引起告警的实体 "fingerprint": <string> // 识别告警的指纹 }, ... ]}
下面一个可以与此功能集成的接收器列表。
<wechat_config>
微信通知是通过微信 API 发送的。
# 是否需要通知已解决的告警。[ send_resolved: <boolean> | default = false ]
# 当与 WeChat API 通信时使用的 API 密钥。[ api_secret: <secret> | default = global.wechat_api_secret ]
# WeChat API 的 URL。[ api_url: <string> | default = global.wechat_api_url ]
# 认证所需的企业 ID。[ corp_id: <string> | default = global.wechat_api_corp_id ]
# 根据 WeChat API 的定义的 API 请求数据。[ message: <tmpl_string> | default = '{{ template "wechat.default.message" . }}' ]# 消息类型,支持的值是 `text` 和 `markdown`。[ message_type: <string> | default = 'text' ][ agent_id: <string> | default = '{{ template "wechat.default.agent_id" . }}' ][ to_user: <string> | default = '{{ template "wechat.default.to_user" . }}' ][ to_party: <string> | default = '{{ template "wechat.default.to_party" . }}' ][ to_tag: <string> | default = '{{ template "wechat.default.to_tag" . }}' ]
<webex_config>
# 是否需要通知已解决的告警。[ send_resolved: <boolean> | default = true ]
# Webex Teams API URL,即 https://webexapis.com/v1/messages# 如果未指定,将使用默认的 API URL。[ api_url: <string> | default = global.webex_api_url ]
# 将消息发送到的 Webex Teams 聊天室的 ID。room_id: <string>
# 消息模版[ message: <tmpl_string> default = '{{ template "webex.default.message" .}}' ]
# HTTP 客户端的配置。你必须使用此配置来提供机器人令牌作为 HTTP “Authorization” 头的一部分。[ http_config: <http_config> | default = global.http_config ]
该文档基于 Prometheus 官方文档翻译而成。