openenvforge's picture
3amBench v0.2.0
44084af verified
|
Raw History Blame Contribute Delete
7.05 kB

alerting

This is where Trevo Pagamentos'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 INFRA- 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.

What's where

  • rules/: alerting and recording rules.
  • alertmanager/alertmanager.yml: routing tree, receivers, inhibition rules.
  • slo/services.yaml: the SLO catalog, the one place for targets, SLO windows, SLI families and traffic floors.
  • teams/ownership.yaml: the team that owns each service. If a runbook disagrees, this file is right.
  • docs/adr/: decisions (burn-rate policy, scrape intervals, disk alerts).
  • runbooks/*.md: what each alert is for and how fast it has to 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/: a smoke suite. Not a spec.

bin/af-check is CI (promtool check, the smoke tests, amtool check-config). bin/range2test turns a query_range pull from an incident packet into a promtool test so you can replay it against a branch.

A word on old files: they predate the rules below, and we don't reformat them in drive-by changes. Groups all evaluate at the global interval (1m); interval:, query_offset: and limit: aren't used on groups here. Reading ALERTS or ALERTS_FOR_STATE from a rule is off limits; the only allowed case is an alert holding up its own firing series. Holding one alert back while another fires is Alertmanager's job (inhibition), visible to on-call. The deploy job fails on any symlink in the repo, so copy files rather than linking them.

What this Prometheus sees

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 0003 has the scrape interval of every job. A rate window should cover about four scrape intervals.

Severity and paging

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.

Who gets what

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-<team> + slack-<team> + slack-sre-fyi
ticket jira-<team> + slack-<team>
warning slack-<team> 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.

Down alerts

One Down alert per service, named <ServiceCamel>Down (so checkout-api has CheckoutApiDown). When a service has no healthy target left, and that includes having no targets at all, its owner gets paged within 10 minutes. Targets missing for 2 minutes or less (a restart) must not page. It carries severity: page, team and service.

SLO alerting

Error SLIs are recorded as slo:sli_error:ratio_rate<window> (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<window>, since each service has its own objective. A burn alert reads its own service's SLI records and nothing else; it is called <ServiceCamel>ErrorBudgetBurnFast (severity: page, for: 2m) or <ServiceCamel>ErrorBudgetBurnSlow (severity: ticket, for: 15m) and is labelled severity, team and slo: <service>-availability. Factors: ADR 0007; window: the catalog.

Alert classes

  • Service alerts (<ServiceCamel>HighErrorRatio, <ServiceCamel>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 0011). 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.

Inhibitions

  • 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]. Cluster-level alerts carry no service; the list is ClusterUnreachable. When ClusterUnreachable fires it pages platform (pagerduty-platform) and holds back the service pages in that cluster, equal: [cluster].

Runbooks

runbook_url is https://runbooks.int.trevopag.example/alerts/<AlertName>. The site is built from runbooks/*.md in this repo, and each page lists the alerts it covers in its front matter.

Contacts

  • Questions: #obs-help. Office hours Tuesday and Thursday afternoons.
  • Urgent routing problems out of hours: the SRE rota (pagerduty-sre).
  • Reviews: observability for anything under alertmanager/; the owning team for its rules.