Alertmanager does not load webhook_config



我想为alertmanager创建新的接收器和路由,以便将心跳发送到OpsGenie。

我试图通过定义opsgenie_config来实现这一点,但我无法将ping发送到opsgenie中的心跳(我可以使用相同的api密钥向opsgenie发送警报(。

我发现的另一种方法是使用webhook_config(如#444中所建议的(,我的清单如下:

apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: opsgenie-webhook
labels:
managedBy: team-sre
spec:
receivers:
- name: heartbeat
webhookConfigs:
- httpConfig:
basicAuth:
password:
name: opsgenie-api-key
key: address
url: https://api.opsgenie.com/v2/heartbeats/sre-test-cluster/ping
route:
groupWait: 0s
repeatInterval: 1m
groupInterval: 1m
matchers:
- name: alertname
value: Watchdog
receiver: heartbeat

当我应用清单时,所描述的接收器和路由不会加载到Alertmanager。当我检查日志时,没有记录任何错误,但也没有消息表明sidecar试图加载新的alertmanagerconfig。

有人经历过同样的问题并知道如何解决吗?

我找到了github问题#3970的解决方案要接受basicAuth,必须同时提供用户名和密码。不错的破解方法是将用户名设置为:base64格式(Og==(。清单应定义如下:

apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
labels:
managedBy: team-sre
name: alertmanager-opsgenie-config
namespace: monitoring
spec:
receivers:
- name: deadmansswitch
webhookConfigs:
# url link to the specific heartbeat, replace test with heartbeat name
- url: 'https://api.opsgenie.com/v2/heartbeats/<hearbeat-name>/ping'
sendResolved: true
httpConfig:
basicAuth:
# reference to secret containing login credentals
password:
key: apiKey
name: opsgenie
username:
key: username
name: opsgenie
route:
groupBy:
- job
groupInterval: 10s
groupWait: 0s
repeatInterval: 10s
matchers:
- name: alertname
value: Watchdog
- name: namespace
value: monitoring
receiver: deadmansswitch
---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: opsgenie
type: Opaque
data:
# apiKey in encoded in base64
apiKey: YOUR_PASSWORD
# ':' in base 64 - fix suggested in https://github.com/prometheus-operator/prometheus-operator/issues/3970#issuecomment-888893008
username: Og==

在应用清单并触发与标准匹配的警报定义后,Opsgenie会被心跳击中。

相关内容

  • 没有找到相关文章

最新更新