# monitoring Alerting rules and routing for Onda Play, maintained by observability. If you own a service, open a `INFRA-` ticket for changes and expect to review the ones to your rules. One Alertmanager serves this Prometheus as well as the platform and data ones, so plenty of the routing below is for alerts defined elsewhere. ## What's where | what | where | authoritative for | |---|---|---| | alerting and recording rules | `rules/` | | | routing, receivers, inhibition | `alertmanager/alertmanager.yml` | | | SLO catalog | `slo/services.yaml` | targets, SLO windows, SLI families, traffic floors | | who owns what | `teams/ownership.yaml` | team of every service (wins over anything a runbook says) | | policies | `docs/adr/` | burn-rate policy, scrape intervals, disk alerts | | runbooks | `runbooks/*.md` | what an alert is for and how fast it has to page | | incident packets | `incidents/` | PagerDuty and postmortem times are the ones to trust; Slack exports are in local time, give or take a minute | | smoke tests | `tests/visible/` | just the smoke suite, 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. Older files predate the conventions below; don't reformat them in passing. All groups run at the global evaluation interval (1m); we don't use `interval:`, `query_offset:` or `limit:` on groups. Rules don't read `ALERTS` or `ALERTS_FOR_STATE` (an alert keeping its own firing series up is the one exception we allow): when one alert should hold another back, that's an inhibition rule in Alertmanager, where on-call can see it. The deploy job refuses a repo with symlinks in it, anywhere, so there are none: copy a file instead of linking it. ## What this Prometheus sees What we can see from here: our apps and the ingress. App targets are relabelled with `service` (the Kubernetes Service name) and `pod`; `up{service="…"}` lists a service's targets. Platform runs the Prometheus with the kubelet and kube-state-metrics in it, and we don't alert from that one. They federate a few cAdvisor container series into ours (`container_memory_*`, `container_spec_*`, `container_cpu_*`), and nothing from kube-state-metrics. The vendor's synthetic checks only watch the public homepage, so liveness here means `up` and the services' own request counters. Per-job scrape intervals: ADR 0005. Rate windows are sized at roughly four scrape intervals. ## Severities `page` wakes someone up. `critical` is the older spelling of `page`: it routes and pages the same way, and new rules use `page`. `warning` pages nobody. Generation-1 files still have a few two-tier alerts with a `warning` and a `critical` copy. We page when users are hurt now, or will be within the hour, and whoever gets paged can act on it. Everything else is a ticket (`severity: ticket`), which lands in the owning team's queue. ## Kinds of alerts - **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 0013). `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`. ## Down alerts Each service has one Down alert, `Down` (`checkout-api` → `CheckoutApiDown`). It pages the owning team within 10 minutes of the service losing its last healthy target, including when the targets are gone. A restart that drops targets for up to 2 minutes must not page. Labels: `severity: page`, `team`, and `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 0010; 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`: - `page` and `critical`: `pagerduty-`, `slack-`, `slack-sre-fyi` - `ticket`: `jira-`, `slack-` - `warning`: `slack-` 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 Between two services' own alerts, `equal: [service]`, so one service's outage never silences another's. A critical copy of an alert holds back the warning copy of the same alert for the same service: `equal: [alertname, service]`. ## Runbooks `runbook_url` is `https://runbooks.int.ondaplay.example/alerts/`. The site is built from `runbooks/*.md` in this repo, and each page lists the alerts it covers in its front matter. ## Known exceptions | where | what | why it's still there | |---|---|---| | `rules/legacy-content-pipeline.yml`, `rules/legacy-discovery.yml`, `rules/legacy-playback.yml` | inline ratios, two-tier warning/critical copies, quoted durations | generation 1; moved out when someone has a reason to touch them | | `rules/ingest-rules.yaml`, `rules/subscriptions-rules.yaml` | PrometheusRule manifests | those teams deploy rules with the operator | | fleet files (`node-exporter`, `postgres`, ...) | upstream thresholds | nobody has tuned them | | `slack-ops-legacy` receiver | routes nothing | kept until its last user is confirmed gone |