kubernetes Alertmanager失败,原因是“解封错误:第19行:在类型config.plain中找不到字段匹配器”

3xiyfsfu  于 2023-10-17  发布在  Kubernetes
关注(0)|答案(2)|浏览(173)

我正在尝试将自定义的alert-routing配置添加到alertmanager,部署为kube-prometheus-stack的一部分。但是prometheus-operator pod在尝试生成alertmanager的Map时,由于以下错误而失败:

level=error ts=2021-05-31T06:29:38.883470881Z caller=klog.go:96 component=k8s_client_runtime func=ErrorDepth msg="Sync \"infra-services/prometheus-operator-kube-p-alertmanager\" failed: provision alertmanager configuration: base config from Secret could not be parsed: yaml: unmarshal errors:\n line 19: field matchers not found in type config.plain"

我还在alertmanager容器中使用amtool验证了同样的错误,它给出了同样的错误。下面是我的alertmanager.yml文件:

global:
  resolve_timeout: 5m
  slack_api_url: https://hooks.slack.com/services/xxxxxx/yyyyy/zzzzzzzzzzz
receivers:
- name: slack-notifications
  slack_configs:
  - channel: '#alerts'
    send_resolved: true
    text: '{{ template "slack.myorg.text" . }}'
- name: blackhole-receiver
route:
  group_by:
  - alertname
  group_interval: 5m
  group_wait: 30s
  receiver: blackhole-receiver
  repeat_interval: 12h
  routes:
  - matchers:
    - severity=~"warning|critical"
    receiver: slack-notifications
templates:
- /etc/alertmanager/config/*.tmpl

我遵循https://prometheus.io/docs/alerting/latest/configuration/https://github.com/prometheus/alertmanager/blob/master/doc/examples/simple.yml来编写简单的alertmanager配置。

7vhp5slm

7vhp5slm1#

尝试从以下更改:

routes:
  - matchers:
    - severity=~"warning|critical"
    receiver: slack-notifications

收件人:

routes:
    - match_re:
        severity: "warning|critical"
      receiver: slack-notifications
wfveoks0

wfveoks02#

升级到(至少)quay.io/prometheus/alertmanager:v0.22.2,它就会工作。
最好不要继续使用match_re,因为它已被弃用。

相关问题