This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.10.8. 应用自定义 Alertmanager 配置
您可以通过编辑 Alertmanager 平台实例的 openshift-monitoring
命名空间中的 alertmanager-main
secret 来覆盖默认的 Alertmanager 配置。
先决条件
-
您可以使用具有
cluster-admin
集群角色的用户身份访问集群。
流程
要从 CLI 更改 Alertmanager 配置:
将当前活跃的 Alertmanager 配置输出到
alertmanager.yaml
文件:oc -n openshift-monitoring get secret alertmanager-main --template='{{ index .data "alertmanager.yaml" }}' | base64 --decode > alertmanager.yaml
$ oc -n openshift-monitoring get secret alertmanager-main --template='{{ index .data "alertmanager.yaml" }}' | base64 --decode > alertmanager.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 编辑
alertmanager.yaml
中的配置:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
group_wait
值指定,Alertmanager 在为一组警报发送初始通知前要等待的时间。这个值控制 Alertmanager 在发送通知前为同一组收集初始警报时等待的时间。- 2
group_interval
值指定 Alertmanager 发送通知添加到已经发送初始通知的一组警报前必须经过的时间。- 3
repeat_interval
值指定重复警报通知前必须经过的最小时间。如果您希望通知在每个组间隔重复,请将repeat_interval
值设置为小于group_interval
的值。但是,重复的通知仍然可能延迟,例如,当某些 Alertmanager pod 重启或重新调度时。- 4
service
值指定触发警报的服务。- 5
<your_matching_rules>
值指定目标警报。- 6
receiver
值指定用于警报的接收器。
注意使用
matchers
键名称来指示警报要与节点匹配的匹配者。不要使用match
或match_re
键名称,它们都已弃用,并计划在以后的发行版本中删除。另外,如果您定义了禁止规则,请使用
target_matchers
键名称来指示目标匹配者和source_matchers
键名称来指示源匹配器。不要使用target_match
,target_match_re
,source_match
, 或source_match_re
键名称,这些名称已弃用,并计划在以后的发行版本中删除。以下 Alertmanager 配置示例将 PagerDuty 配置为警报接收器:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 采用此配置时,由
example-app
服务触发的、严重性为critical
的警报将使用team-frontend-page
接收器发送。通常情况下,这些类型的警报会传给个人或关键响应团队。应用文件中的新配置:
oc -n openshift-monitoring create secret generic alertmanager-main --from-file=alertmanager.yaml --dry-run=client -o=yaml | oc -n openshift-monitoring replace secret --filename=-
$ oc -n openshift-monitoring create secret generic alertmanager-main --from-file=alertmanager.yaml --dry-run=client -o=yaml | oc -n openshift-monitoring replace secret --filename=-
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
要从 OpenShift Container Platform Web 控制台更改 Alertmanager 配置:
-
进入到 web 控制台的 Administration
Cluster Settings Configuration Alertmanager YAML 页面。 - 修改 YAML 配置文件。
- 选择 Save。