Alertmanager 由于 "unmarshal errors: line 19: field matchers not found in type config.plain" 而失败

Alertmanager failing due to "unmarshal errors: line 19: field matchers not found in type config.plain"

我正在尝试将自定义警报路由配置添加到我的警报管理器中,作为 kube-prometheus-stack 的一部分进行部署。但是 prometheus-operator pod 在尝试生成 alertmanager configmap 时由于以下错误而失败:

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/ and https://github.com/prometheus/alertmanager/blob/master/doc/examples/simple.yml 编写了简单的 alertmanager 配置。

尝试更改自:

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

收件人:

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

升级到(至少)quay。io/prometheus/alertmanager:v0.22.2 它肯定会工作。

您不应该继续使用 match_re,因为它已被弃用。