Configuring Alertmanager — routing Prometheus's default rules to a webhook
Configuring Alertmanager — routing Prometheus's default rules to a webhook
Step-by-step guide to turn on real delivery of kube-prometheus-stack's 35 default rules (the ones we already saw under Alerting → Prometheus in Grafana) to a webhook, without touching the rules' content yet — only routing/delivery. Full context (what exists, what's missing, why) is in ALERTING-PLAN.md; this doc is the mechanical "how".
0. Decision: block in values.yaml, not AlertmanagerConfig CRD
The original plan left the AlertmanagerConfig CRD option open for being more agile to iterate on (no helm upgrade every time). Changing the recommendation for this first wiring pass: use the alertmanager.config block directly in prometheus-stack-values.yaml.
Why the change: when the Prometheus operator merges several AlertmanagerConfig CRDs into the final config, by default it automatically injects a namespace: <CRD's-namespace> matcher into every route (alertmanagerConfigMatcherStrategy, default OnNamespace). Since our 35 rules fire with the real namespace of wherever the problem is happening (kube-system, default, bakery's namespace, etc.) and not namespace: monitoring, an AlertmanagerConfig living in monitoring would never match anything unless we also change that behavior globally. It's solvable, but it's an easy trap to fall into without realizing it. The block in values.yaml is Alertmanager's root config directly — no such problem, no surprises. If you want team-level self-service via CRD later on, revisit option B with alertmanagerConfigMatcherStrategy.type: None set on purpose.
1. How we tell it the rules: by severity, not by name
The 35 default rules already carry the severity label (critical / warning / info) on every alert — no need to touch any rule or list alertnames one by one. We route by that label:
severity: critical→ gets delivered now, shortrepeat_interval(e.g. 1h).severity: warning→ also delivered but with a longrepeat_interval, digest-style (e.g. 24h).severity: info→ not routed to any real receiver — already suppressed by the defaultinhibit_rules(reproduced below) whenever there's awarning/criticalfor the samealertname+namespace.
2. How the webhook gets set
A webhook_configs receiver with the destination URL. Right now the adapter that translates Alertmanager's format to Google Chat doesn't exist yet (pending, see ALERTING-PLAN.md §5) — two ways to move forward without getting blocked waiting on that function:
Quick option to test routing right away: use a temporary URL from webhook.site (gives you a unique URL, you see every POST that hits it right there in the browser) — good enough to confirm Alertmanager groups/routes correctly before the real receiver exists.
Once the adapter exists: change a single value (the receiver's
url:) and reapply — nothing else needs to change.
Leaving the file with an explicit placeholder (REPLACE_ME) so it's not accidentally applied with the real URL still missing.
3. The full file
Edit gke/monitoring/prometheus-stack-values.yaml, add the config: key inside the existing alertmanager: block (the one that already has the storage: we set up earlier):
alertmanager:
alertmanagerSpec:
storage:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 2Gi
config:
global:
resolve_timeout: 5m
route:
receiver: "null"
group_by: ["namespace", "alertname"]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
routes:
# Watchdog: synthetic alert kube-prometheus-stack always fires on purpose,
# only used to confirm the alerting pipeline is alive. Not sent anywhere.
- receiver: "null"
matchers:
- alertname = "Watchdog"
- receiver: "google-chat"
matchers:
- severity = "critical"
repeat_interval: 1h
- receiver: "google-chat"
matchers:
- severity = "warning"
repeat_interval: 24h
# severity=info falls through to the "null" receiver by default (not listed separately on purpose)
receivers:
- name: "null"
- name: "google-chat"
webhook_configs:
- url: "REPLACE_ME_webhook_url"
send_resolved: true
# Same inhibit_rules the cluster already ships with by default (we saw them by reading the
# generated config directly) - reproduced here because setting "config:" by hand replaces
# ALL of the generated config, including this, so if we don't copy it, it's lost.
inhibit_rules:
- source_matchers:
- severity = "critical"
target_matchers:
- severity =~ "warning|info"
equal: ["namespace", "alertname"]
- source_matchers:
- severity = "warning"
target_matchers:
- severity = "info"
equal: ["namespace", "alertname"]
- source_matchers:
- alertname = "InfoInhibitor"
target_matchers:
- severity = "info"
equal: ["namespace"]
- target_matchers:
- alertname = "InfoInhibitor"
4. Apply
helm upgrade prometheus prometheus-community/kube-prometheus-stack \
--namespace monitoring \
-f prometheus-stack-values.yaml
This restarts the Alertmanager pod (new config mounted), not Grafana's or Prometheus's.
5. Verify it went well
# The pod should come back Running 2/2
kubectl get pods -n monitoring -l app.kubernetes.io/name=alertmanager
# Check the config that actually got loaded (to confirm it's not still receiver: "null" everywhere)
kubectl get secret -n monitoring alertmanager-prometheus-kube-prometheus-alertmanager-generated \
-o jsonpath='{.data.alertmanager\.yaml\.gz}' | base64 -d | gunzip
# Alertmanager UI, to see live that it's grouping/routing correctly (if you set webhook.site,
# you'll see the POSTs arrive right there on its page)
kubectl port-forward -n monitoring svc/prometheus-kube-prometheus-alertmanager 9093:9093
# open http://localhost:9093
There's also an ingress with TLS + basic auth so you don't have to rely on port-forward — see
ingress/alertmanager.yaml. It requires creating the
alertmanager-basic-auth secret first (kubectl create secret generic alertmanager-basic-auth --namespace monitoring --from-file=auth=<htpasswd>) and applying the ingress; it ends up at https://alertmanager.webforcehq.io.
The externalUrl in the alertmanager.alertmanagerSpec block in prometheus-stack-values.yaml
already points at that domain, so the "Open Alertmanager" button in notifications opens there
instead of an internal cluster URL.
If something among the 35 default rules is already firing (check Alerting → Prometheus in Grafana to see if anything is in firing state right now), it should show up in the Alertmanager UI, and if the receiver has a valid URL, the POST should arrive. If nothing is firing right now, a test alert can be forced with amtool to confirm routing without waiting for something real to fire — left pending if you need it.
Pending (outside this doc)
Build the real adapter that receives Alertmanager's webhook and sends it to Google Chat (new folder at the root of
project, same pattern askuma-proxy) — today theurl:above is a placeholder.Exclude the control-plane rule groups (
etcd,kubernetes-system-apiserver,-scheduler,-controller-manager) from routing if they're confirmed to generate noise — on GKE, Google manages the control plane and those rules will most likely never have data to evaluate, so they shouldn't fire anything to begin with; only worth excluding explicitly if the opposite is observed. Couldn't verify the exact live state of those groups in this session due to agcloudcredentials issue (expired session, requires interactive reauth) — whenever convenient, rungcloud auth loginand we can confirm withcurl .../api/v1/rulesagainst Prometheus.