# monitoring This is where Linnea Vård's alerting lives: the rules our Prometheus evaluates and the Alertmanager config every Prometheus in the company sends to. Observability owns it; teams ask for changes with `OPS-` tickets and review whatever touches their own rules. The platform and data Prometheus servers use the same Alertmanager, which is why many team subtrees route alerts this repo never fires. ## Where things live | path | contents | source of truth for | |---|---|---| | `rules/` | every alerting and recording rule | | | `alertmanager/alertmanager.yml` | routes, receivers, inhibitions | | | `slo/services.yaml` | the SLO catalog | SLO targets and windows, SLI family per service, traffic floors | | `teams/ownership.yaml` | owners | which team owns each service; beats any runbook | | `docs/adr/` | decisions | burn-rate policy, scrape intervals, disk alerts | | `runbooks/*.md` | one page per alert or service | what the alert means, how quickly it must page | | `incidents/` | packets from past incidents | PagerDuty exports and postmortems are the authoritative times; Slack threads are local time and can be a minute off. | | `tests/visible/` | the smoke suite | nothing; it is not a spec | CI is `bin/af-check`: promtool check, the smoke tests, amtool check-config. To replay an incident against a branch, feed one of the packet's `query_range` pulls to `bin/range2test` and run the promtool test it writes. Some files are older than the conventions here. Leave their formatting alone unless you are changing them for a reason. Every group runs at the global evaluation interval of 1m: no `interval:`, `query_offset:` or `limit:` on a group. No rule reads `ALERTS` or `ALERTS_FOR_STATE`, except an alert that keeps its own firing series up. If one alert should silence another, write an inhibition rule in Alertmanager so on-call can see it. No symlinks anywhere in the repo: the deploy job rejects them. Copy the file instead. ## Scrape targets We scrape the app pods and the ingress controller. Relabelling puts the Kubernetes Service name in `service` and the pod name in `pod` on every app target, so a service's targets are `up{service="…"}`. The kubelet and kube-state-metrics are scraped by platform's Prometheus and we don't alert on them; platform federates an allowlist of cAdvisor series to us (`container_memory_*`, `container_spec_*`, `container_cpu_*`), none from kube-state-metrics. The uptime vendor's synthetic checks cover the public homepage only. That leaves `up` and each service's own request counters as our liveness signals. ADR 0004 has the scrape interval of every job. A rate window should cover about four scrape intervals. ## Paging policy - `page`: wakes someone up. - `critical`: the old name for `page`. Routed and paged exactly like it; write `page` in new rules. - `warning`: pages nobody. - `ticket`: lands in the owning team's queue. Some generation-1 alerts still exist twice, as a `warning` and a `critical` copy. The rule for paging: users are affected now or will be within the hour, and the person who gets paged can act. If not, it's a ticket. ## Alert classes - **Service alerts** (`HighErrorRatio`, `Down`, burn alerts) page the owning team. Service error alerts are per service, never per pod; one page per service per outage. They use a 5m window and `for: 10m`. Errors are 5xx; 4xx are the caller's problem. - **Capacity alerts** (`ContainerMemoryNearLimit`, disk) open a ticket for the owning team, except where an ADR says a level pages (disk: ADR 0015). `ContainerMemoryNearLimit` opens a ticket when a container keeps reaching 90% of its memory limit for 10 minutes. One busy 5-minute stretch isn't that. We want the ticket inside 20 minutes of the first time it reaches 90%, which leaves time before the OOM. - **Fleet alerts** (node, database, cache, broker exporters) are `infra`'s, `severity: warning`, and page nobody. - Any other alert keeps the `severity` and `team` it has unless a ticket says otherwise. Ticket alerts carry `service` like pages do. Every alert has labels `severity` and `team`. Service, capacity and ticket alerts also carry `service` on the alert (from the expression or as a static label). Annotations: a `summary` that says what is affected, and `runbook_url`. ## Service health `Down` (for `checkout-api`: `CheckoutApiDown`) is the only Down alert a service has. Lose the last healthy target, or lose the targets altogether, and the owning team is paged within 10 minutes; a restart that takes targets away for at most 2 minutes doesn't page. Labels `severity: page`, `team`, `service`. ## SLO alerting Error SLIs are recorded as `slo:sli_error:ratio_rate` (windows 5m, 30m, 1h, 6h): the fraction of bad requests `by (service)`, one record per window for every service with the family's metrics. Don't add a service filter to them. Latency SLIs are recorded per service as `slo:sli_latency:ratio_rate`, since each service has its own objective. A burn alert reads its own service's SLI records and nothing else; it is called `ErrorBudgetBurnFast` (`severity: page`, `for: 2m`) or `ErrorBudgetBurnSlow` (`severity: ticket`, `for: 15m`) and is labelled `severity`, `team` and `slo: -availability`. Factors: ADR 0008; window: the catalog. ## Routing The `team` label on the alert is the routing key and has to match `teams/ownership.yaml`. Each team has a subtree matching its `team`: | alert severity | delivered to | |---|---| | `page` or `critical` | `pagerduty-` + `slack-` + `slack-sre-fyi` | | `ticket` | `jira-` + `slack-` | | `warning` | `slack-` only | SRE watches every page in #sre-fyi (`slack-sre-fyi`); nobody is paged from there. The root receiver `slack-alerts-default` is the catch-all for alerts with no `team`; nobody is on it. Rule evaluation failures go to `slack-prometheus-meta`. The paging unit is the service: one page per service per outage; two services failing together are two pages, even for the same team. Don't change receivers you don't own, `global`, or add time intervals. ## Inhibition rules - service alerts holding back other service alerts: always `equal: [service]`, so no outage silences another service. - critical copy over warning copy of the same alert for the same service: `equal: [alertname, service]`. ## Runbooks Runbook links point at `https://runbooks.linneavard.example/alerts/`. That site is generated from `runbooks/*.md` here; a page's front matter lists the alerts it covers. ## Changelog - 2025-11: burn alerts moved to the SLI records (ADR 0008). - 2026-02: `slack-sre-fyi` added; SRE stopped being paged for every team. - 2026-05: disk alerts per ADR 0015. - 2026-08: kafka-exporter scraped every 1m instead of 15s (ADR 0004).