prometheus - 允许 Prometheus alertmanager 接收器字段中的模板化字段
问题描述
我正在尝试实施布赖恩巴西在这里提出的建议:
https://www.robustperception.io/using-labels-to-direct-email-notifications/
我正在做的是将 OpenShift 命名空间注释添加到我的指标中,然后使用 Alertmanager 配置获取该标签。但它似乎不起作用,并抱怨“to”字段为空。
time="2018-06-26T13:28:48Z" level=debug msg="Notify attempt 1 for "email" failed: parsing to addresses: mail: no address" source="notify.go:585"
time="2018-06-26T13:28:48Z" level=error msg="Error on notify: Cancelling notify retry for "email" due to unrecoverable error: parsing to addresses: mail: no address" source="notify.go:283"
time="2018-06-26T13:28:48Z" level=error msg="Notify for 6 alerts failed: Cancelling notify retry for "email" due to unrecoverable error: parsing to addresses: mail: no address" source="dispatch.go:262"
以下是我尝试过的一些配置:
# default route if none match
group_by: [annotation_contact_email]
receiver: projectalerts
group_by: []
group_wait: 0s
group_interval: 2s
repeat_interval: 2s
receivers:
- name: alert-buffer-wh
webhook_configs:
- url: http://localhost:9099/topics/alerts
- name: projectalerts
email_configs:
- to: '{{.GroupLabels.annotation_contact_email}}'
并且
- name: projectalerts
email_configs:
- to: '{{.Labels.annotation_contact_email}}'
它适用于静态定义的电子邮件。
解决方案
我终于用它来工作了:
global:
# The root route on which each incoming alert enters.
route:
# default route if none match
group_by: [annotation_contact_email]
receiver: projectalerts
# The labels by which incoming alerts are grouped together. For example,
# multiple alerts coming in for cluster=A and alertname=LatencyHigh would
# be batched into a single group.
# TODO:
#group_by: []
group_wait: 0s
group_interval: 5s
repeat_interval: 3600s
# All the above attributes are inherited by all child routes and can
# overwritten on each.
receivers:
- name: alert-buffer-wh
webhook_configs:
- url: http://localhost:9099/topics/alerts
- name: projectalerts
email_configs:
- to: "{{ .GroupLabels.annotation_contact_email }}"
推荐阅读
- javascript - Select2 多选下拉自定义搜索
- java - Apache Storm 服务停止
- javascript - 在socket.io编程中,所有客户端同时调用一个服务器
- javascript - 为什么 React 的状态机会更改不可变变量?
- c# - 为什么 Entity Framework Core 渴望加载未包含的相关实体
- reactjs - 是否总是在渲染之前调用 componentWillRecieveProps 还是以其他方式
- jquery - 如何手动向函数添加数据
- javascript - 我有一个对象数组和一个对象,我想循环一个对象,同时将对象值与数组中的值匹配
- javascript - 获得实际输出 JavaScript 后,我变得不确定
- java - 如何从随机二进制文件上传集合?