prometheus / alertmanager

Prometheus Alertmanager
https://prometheus.io
Apache License 2.0
6.68k stars 2.16k forks source link

Slack receiver is being ignored #3437

Closed droslean closed 1 year ago

droslean commented 1 year ago
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  name: alertmanagerconfig
  namespace: monitoring
  labels:
    alertmanagerConfig: global
spec:
  route:
    receiver: 'slack-notifications'
  receivers:
  - name: 'slack-notifications'
    slackConfigs:
    - apiURL:
        name: slack-webhook
        key: slack_api_url
      channel: '#monitoring'
      sendResolved: true
      title: "{{ range .Alerts }}{{ .Annotations.summary }}\n{{ end }}"
      text: "{{ range .Alerts }}{{ .Annotations.description }}\n{{ end }}"

My alert which is being sent by the Prometheus:

alertname="InstanceNotReporting"
domain="example.com"
prometheus="monitoring/prometheus"
severity="critical"

I exec into the pod to see what the config_out looks like

/etc/alertmanager/config_out $ cat alertmanager.env.yaml 
route:
  receiver: "null"
  routes:
  - receiver: monitoring/alertmanagerconfig/slack-notifications
    matchers:
    - namespace="monitoring"
    continue: true
receivers:
- name: "null"
- name: monitoring/alertmanagerconfig/slack-notifications
  slack_configs:
  - send_resolved: true
    api_url: https://hooks.slack.com/services/XXXXXXXXXXXXXXXX
    channel: '#monitoring'
    title: |-
      {{ range .Alerts }}{{ .Annotations.summary }}
      {{ end }}
    text: |-
      {{ range .Alerts }}{{ .Annotations.description }}
      {{ end }}
templates: []

The debug logs of the Alertmanager

ts=2023-08-01T20:04:15.628Z caller=dispatch.go:515 level=debug component=dispatcher aggrGroup={}:{} msg=flushing alerts=[InstanceNotReporting[de1a7ab][active]]
ts=2023-08-01T20:04:45.606Z caller=dispatch.go:163 level=debug component=dispatcher msg="Received alert" alert=InstanceNotReporting[de1a7ab][active]
ts=2023-08-01T20:06:15.605Z caller=dispatch.go:163 level=debug component=dispatcher msg="Received alert" alert=InstanceNotReporting[de1a7ab][active]

It seems the slack receiver is completely ignored and there are no logs. I failed to find any misconfiguration, therefore there is a chance of a BUG.

I am using quay.io/prometheus-operator/prometheus-operator:v0.66.0 for the Prometheus operator.

droslean commented 1 year ago

Closing in favor of https://github.com/prometheus-operator/prometheus-operator/issues/3737

For the record, the solution is either to create an AlertmanagerConfig per namespace or set spec.alertmanagerConfigMatcherStrategy.type to None in the Alertmanager CR.