mr-karan / calert

🔔 Send alert notifications to Google Chat via Prometheus Alertmanager
MIT License
155 stars 58 forks source link

no provider available for room #75

Open ybucci opened 8 months ago

ybucci commented 8 months ago

Error LOG

(*Notifier).Dispatch","file":"/home/runner/work/calert/calert/internal/notifier/notifier.go","line":41},"msg":"dispatching alerts","count":1}
{"time":"2024-03-26T17:01:19.101881613Z","level":"ERROR","source":{"function":"github.com/mr-karan/calert/internal/notifier.(*Notifier).Dispatch","file":"/home/runner/work/calert/calert/internal/notifier/notifier.go","line":45},"msg":"no provider available for room","room":"cattle-monitoring-system/alertas/alertas"}
{"time":"2024-03-26T17:01:19.102244707Z","level":"ERROR","source":{"function":"main.handleDispatchNotif.func1","file":"/home/runner/work/calert/calert/cmd/handlers.go","line":109},"msg":"error dispatching alerts","error":"no provider configured for room: cattle-monitoring-system/alertas/alertas"}

AlertManager Config

apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  name: alertas
  namespace: cattle-monitoring-system
spec:
  receivers:
    - name: alertas
      webhookConfigs:
        - url: http://caalert-calert:6000/dispatch
  route:
    groupBy:
      - job
    groupInterval: 5m
    groupWait: 30s
    receiver: alertas
    repeatInterval: 12h

ConfigMap

   [providers.alertas]

    type = "google_chat"

    endpoint =
    "https://chat.googleapis.com/v1/spaces/XXXXXXXXXXXXXXXXXXXXXXXXX"

    max_idle_conns = 50

    timeout = "30s"

    proxy_url = ""

    template = "static/message.tmpl"

    thread_ttl = "12h"

    dry_run = "false"
NotLGBT commented 7 months ago

Understood?

calert configuration

calert: prod_alerts: type: "google_chat" endpoint: "https://chat.googleapis.com/v1/spaces//messages?key=&token=" max_idle_conns: 50 timeout: "30s" template: "static/message.tmpl" thread_ttl: "12h" dry_run: false

dev_alerts: type: "google_chat" endpoint: "https://chat.googleapis.com/v1/spaces//messages?key=&token=" max_idle_conns: 50 timeout: "30s" template: "static/message.tmpl" thread_ttl: "12h" dry_run: false

Alertmanager configuration

receivers:

Ancocodet commented 6 months ago

The Problem is that in Kubernetes (which your configuration looks like) the rooms/receivers are always prefixed with the namespace and the name of config (namespace/config_name/receiver). You can use the query parameter room_name with the dispatch endpoint and set it to the receiver name, that should fix the error.

For example:

apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  name: alertas
  namespace: cattle-monitoring-system
spec:
  receivers:
    - name: alertas
      webhookConfigs:
        - url: http://caalert-calert:6000/dispatch?room_name=alertas
  route:
    groupBy:
      - job
    groupInterval: 5m
    groupWait: 30s
    receiver: alertas
    repeatInterval: 12h