apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: alertmanager-main
  namespace: monitoring
  labels:
    app: alertmanager
    alertmanager: main
stringData:
  alertmanager.yaml: |
    global:
      resolve_timeout: 5m
    route:
      group_wait: 30s
      group_interval: 5m
      repeat_interval: 12h
      receiver: 'telegram-default'
      routes:
        # Warning alerts not important.
        - match:
            severity: warning
          receiver: telegram-warning

        # Only important alerts.
        - match_re:
            severity: ^(oncall|critical)$
          receiver: telegram-oncall

    receivers:
    # Use default alert channel for the default alerts.
    - name: telegram-default
      webhook_configs:
      - url: 'http://alertgram:8080/alerts'
        send_resolved: false

    # Critical and oncall alerts to special channel.
    - name: telegram-oncall
      webhook_configs:
      - url: 'http://alertgram:8080/alerts?chat-id=-1001111111111'
        send_resolved: false

    # Warning alerts to a more public informative channel.
    - name: telegram-warning
      webhook_configs:
      - url: 'http://alertgram:8080/alerts?chat-id=-1002222222222'
        send_resolved: false
