#!/bin/bash # oracle: rewrites changed files to the oracle state set -euo pipefail cd /workspace/monitoring mkdir -p 'alertmanager' cat > 'alertmanager/alertmanager.yml' <<'AF_EOF' # Shared Alertmanager config (this repo, platform and data Prometheus servers). # Receivers belong to the teams; ask before touching someone else's. global: resolve_timeout: 5m slack_api_url_file: /etc/alertmanager/secrets/slack-url templates: - /etc/alertmanager/templates/*.tmpl route: receiver: slack-alerts-default group_by: [alertname, service] group_wait: 30s group_interval: 5m repeat_interval: 4h routes: # rule evaluation problems. Nobody pages on these (yet). - matchers: - alertname=~"PrometheusRuleFailures|PrometheusRuleEvaluationSlow" receiver: slack-prometheus-meta # SRE sees every page as FYI; owners get paged by their own subtree below. - matchers: - severity=~"page|critical" receiver: slack-sre-fyi continue: true # identity: still on the old match syntax - match: team: identity receiver: slack-identity routes: - match_re: severity: page|critical receiver: pagerduty-identity continue: true - match: severity: ticket receiver: jira-identity continue: true - receiver: slack-identity - matchers: - team="core-api" receiver: slack-core-api routes: - matchers: - severity=~"page|critical" receiver: pagerduty-core-api continue: true - matchers: - severity="ticket" receiver: jira-core-api continue: true - receiver: slack-core-api - matchers: - team="integrations" receiver: slack-integrations routes: - matchers: - severity=~"page|critical" receiver: pagerduty-integrations continue: true - matchers: - severity="ticket" receiver: jira-integrations continue: true - receiver: slack-integrations - matchers: - team="billing" receiver: slack-billing routes: - matchers: - severity=~"page|critical" receiver: pagerduty-billing continue: true - matchers: - severity="ticket" receiver: jira-billing continue: true - receiver: slack-billing - matchers: - team="search" receiver: slack-search routes: - matchers: - severity=~"page|critical" receiver: pagerduty-search continue: true - matchers: - severity="ticket" receiver: jira-search continue: true - receiver: slack-search # integrations services from before team labels were everywhere - matchers: - service=~"notifier-svc|webhooks-dispatch" receiver: slack-integrations routes: - matchers: - severity=~"page|critical" receiver: pagerduty-integrations continue: true - receiver: slack-integrations - matchers: - team="reporting" receiver: slack-reporting routes: - matchers: - severity=~"page|critical" receiver: pagerduty-reporting continue: true - matchers: - severity="ticket" receiver: jira-reporting continue: true - receiver: slack-reporting # teams below route alerts from the platform and data Prometheus servers - matchers: - team="edge" receiver: slack-edge routes: - matchers: - severity=~"page|critical" receiver: pagerduty-edge continue: true - matchers: - severity="ticket" receiver: jira-edge continue: true - receiver: slack-edge - matchers: - team="platform" receiver: slack-platform routes: - matchers: - severity=~"page|critical" receiver: pagerduty-platform continue: true - matchers: - severity="ticket" receiver: jira-platform continue: true - receiver: slack-platform - matchers: - team="data-platform" receiver: slack-data-platform routes: - matchers: - severity=~"page|critical" receiver: pagerduty-data-platform continue: true - matchers: - severity="ticket" receiver: jira-data-platform continue: true # tickets and warnings per pod in Slack, so the channel shows which pod; pages group per service above - receiver: slack-data-platform group_by: [alertname, pod, service] - matchers: - team="network" receiver: slack-network routes: - matchers: - severity=~"page|critical" receiver: pagerduty-network continue: true - matchers: - severity="ticket" receiver: jira-network continue: true - receiver: slack-network # messaging wanted tickets in Slack as well as Jira (OPS-1693) - matchers: - team="messaging" receiver: slack-messaging routes: - matchers: - severity=~"page|critical" receiver: pagerduty-messaging continue: true - matchers: - severity="ticket" receiver: jira-messaging continue: true - receiver: slack-messaging - matchers: - team="database-reliability" receiver: slack-database-reliability routes: - matchers: - severity=~"page|critical" receiver: pagerduty-database-reliability continue: true - matchers: - severity="ticket" receiver: jira-database-reliability continue: true - receiver: slack-database-reliability - matchers: - team="storage" receiver: slack-storage routes: - matchers: - severity=~"page|critical" receiver: pagerduty-storage continue: true - matchers: - severity="ticket" receiver: jira-storage continue: true - receiver: slack-storage # ml-platform: fewer updates per group, too chatty at 5m - matchers: - team="ml-platform" receiver: slack-ml-platform group_interval: 10m routes: - matchers: - severity=~"page|critical" receiver: pagerduty-ml-platform continue: true - matchers: - severity="ticket" receiver: jira-ml-platform continue: true - receiver: slack-ml-platform - matchers: - team="security-ops" receiver: slack-security-ops routes: - matchers: - severity=~"page|critical" receiver: pagerduty-security-ops continue: true - matchers: - severity="ticket" receiver: jira-security-ops continue: true - receiver: slack-security-ops receivers: - name: slack-alerts-default slack_configs: - channel: "#alerts-default" send_resolved: true - name: slack-sre-fyi slack_configs: - channel: "#sre-fyi" send_resolved: false - name: slack-prometheus-meta slack_configs: - channel: "#prometheus-meta" - name: pagerduty-sre pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/sre - name: pagerduty-billing pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/billing - name: slack-billing slack_configs: - channel: "#billing-alerts" send_resolved: true - name: jira-billing webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/billing - name: pagerduty-core-api pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/core-api - name: slack-core-api slack_configs: - channel: "#core-api-alerts" send_resolved: true - name: jira-core-api webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/core_api - name: pagerduty-data-platform pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/data-platform - name: slack-data-platform slack_configs: - channel: "#data-platform-alerts" send_resolved: true - name: jira-data-platform webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/data_platform - name: pagerduty-database-reliability pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/database-reliability - name: slack-database-reliability slack_configs: - channel: "#database-reliability-alerts" send_resolved: true - name: jira-database-reliability webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/database_reliability - name: pagerduty-edge pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/edge - name: slack-edge slack_configs: - channel: "#edge-alerts" send_resolved: true - name: jira-edge webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/edge - name: pagerduty-identity pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/identity - name: slack-identity slack_configs: - channel: "#identity-alerts" send_resolved: true - name: jira-identity webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/identity - name: pagerduty-integrations pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/integrations - name: slack-integrations slack_configs: - channel: "#integrations-alerts" send_resolved: true - name: jira-integrations webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/integrations - name: pagerduty-messaging pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/messaging - name: slack-messaging slack_configs: - channel: "#messaging-alerts" send_resolved: true - name: jira-messaging webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/messaging - name: pagerduty-ml-platform pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/ml-platform - name: slack-ml-platform slack_configs: - channel: "#ml-platform-alerts" send_resolved: true - name: jira-ml-platform webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/ml_platform - name: pagerduty-network pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/network - name: slack-network slack_configs: - channel: "#network-alerts" send_resolved: true - name: jira-network webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/network - name: pagerduty-platform pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/platform - name: slack-platform slack_configs: - channel: "#platform-alerts" send_resolved: true - name: jira-platform webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/platform - name: pagerduty-reporting pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/reporting - name: slack-reporting slack_configs: - channel: "#reporting-alerts" send_resolved: true - name: jira-reporting webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/reporting - name: pagerduty-search pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/search - name: slack-search slack_configs: - channel: "#search-alerts" send_resolved: true - name: jira-search webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/search - name: pagerduty-security-ops pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/security-ops - name: slack-security-ops slack_configs: - channel: "#security-ops-alerts" send_resolved: true - name: jira-security-ops webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/security_ops - name: pagerduty-storage pagerduty_configs: - routing_key_file: /etc/alertmanager/secrets/pagerduty/storage - name: slack-storage slack_configs: - channel: "#storage-alerts" send_resolved: true - name: jira-storage webhook_configs: - url: https://jira-bridge.wekalo.example/hooks/storage # nothing routes here since the rota moved to PagerDuty; ask before deleting - name: slack-old-oncall slack_configs: - channel: "#oncall-old" send_resolved: true inhibit_rules: # a critical copy holds back the warning copy of the same alert - source_matchers: - severity="critical" target_matchers: - severity="warning" equal: [alertname, service] - source_matchers: - alertname="BillingSvcDown" target_matchers: - alertname=~"BillingSvcErrorBudgetBurnFast|BillingSvcErrorBudgetBurnSlow|BillingSvcHighErrorRatio" equal: [service] AF_EOF mkdir -p 'rules' cat > 'rules/capacity.yml' <<'AF_EOF' # Capacity tickets. Pages for crashes come from the platform Prometheus. groups: - name: capacity rules: - alert: ContainerMemoryNearLimit expr: | max by (service) (container_memory_working_set_bytes{service="reports-worker",container="reports-worker"} / container_spec_memory_limit_bytes{service="reports-worker",container="reports-worker"}) > 0.9 for: 15m labels: severity: ticket team: reporting annotations: summary: "{{ $labels.service }} keeps running close to its memory limit" runbook_url: https://runbooks.wekalo.example/alerts/ContainerMemoryNearLimit - alert: ContainerMemoryNearLimit expr: | max by (service) (container_memory_working_set_bytes{service="search-indexer",container="search-indexer"} / container_spec_memory_limit_bytes{service="search-indexer",container="search-indexer"}) > 0.9 for: 15m labels: severity: ticket team: search annotations: summary: "{{ $labels.service }} keeps running close to its memory limit" runbook_url: https://runbooks.wekalo.example/alerts/ContainerMemoryNearLimit - alert: ContainerMemoryNearLimit expr: | max by (service) (container_memory_working_set_bytes{service="webhooks-dispatch",container="webhooks-dispatch"} / container_spec_memory_limit_bytes{service="webhooks-dispatch",container="webhooks-dispatch"}) > 0.9 for: 15m labels: severity: ticket team: integrations annotations: summary: "{{ $labels.service }} keeps running close to its memory limit" runbook_url: https://runbooks.wekalo.example/alerts/ContainerMemoryNearLimit AF_EOF mkdir -p 'rules' cat > 'rules/integrations-rules.yaml' <<'AF_EOF' apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: integrations-rules namespace: monitoring labels: role: alert-rules spec: groups: - name: reports-worker rules: - alert: ReportsWorkerDown expr: | sum by (service) (up{service="reports-worker"}) == 0 or absent(up{service="reports-worker"}) for: 3m labels: severity: page team: reporting annotations: summary: reports-worker has no healthy scrape targets runbook_url: https://runbooks.wekalo.example/alerts/ReportsWorkerDown - alert: ReportsWorkerHighErrorRatio expr: | sum by (service) (rate(http_requests_total{service="reports-worker",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="reports-worker"}[5m])) > 0.02 for: 10m labels: severity: page team: reporting annotations: summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" runbook_url: https://runbooks.wekalo.example/alerts/ReportsWorkerHighErrorRatio - name: notifier-svc rules: # absent() too: notifier-svc was scaled to zero by mistake once and the sum just went away - alert: NotifierSvcDown expr: | sum by (service) (up{service="notifier-svc"}) == 0 or absent(up{service="notifier-svc"}) for: 3m labels: severity: page team: integrations annotations: summary: notifier-svc has no healthy scrape targets runbook_url: https://runbooks.wekalo.example/alerts/NotifierSvcDown - alert: NotifierSvcHighErrorRatio expr: | sum by (service) (rate(grpc_server_handled_total{service="notifier-svc",grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m])) / sum by (service) (rate(grpc_server_handled_total{service="notifier-svc"}[5m])) > 0.1 for: 10m labels: severity: page team: integrations annotations: summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" runbook_url: https://runbooks.wekalo.example/alerts/NotifierSvcHighErrorRatio - alert: NotifierSvcErrorBudgetBurnFast expr: | slo:sli_error:ratio_rate1h{service="notifier-svc"} > (14.4 * 0.001) and slo:sli_error:ratio_rate5m{service="notifier-svc"} > (14.4 * 0.001) for: 2m labels: severity: page team: integrations slo: notifier-svc-availability annotations: summary: "{{ $labels.service }} is spending its error budget fast" runbook_url: https://runbooks.wekalo.example/alerts/NotifierSvcErrorBudgetBurnFast - alert: NotifierSvcErrorBudgetBurnSlow expr: | slo:sli_error:ratio_rate6h{service="notifier-svc"} > (6 * 0.001) and slo:sli_error:ratio_rate30m{service="notifier-svc"} > (6 * 0.001) for: 15m labels: severity: ticket team: integrations slo: notifier-svc-availability annotations: summary: "{{ $labels.service }} is spending its error budget steadily" runbook_url: https://runbooks.wekalo.example/alerts/NotifierSvcErrorBudgetBurnSlow - name: audit-export rules: - alert: AuditExportDown expr: | sum by (service) (up{service="audit-export"}) == 0 or absent(up{service="audit-export"}) for: 3m labels: severity: page team: reporting annotations: summary: audit-export has no healthy scrape targets runbook_url: https://runbooks.wekalo.example/alerts/AuditExportDown - name: webhooks-dispatch rules: - alert: WebhooksDispatchDown expr: | sum by (service) (up{service="webhooks-dispatch"}) == 0 or absent(up{service="webhooks-dispatch"}) for: 3m labels: severity: page team: integrations annotations: summary: webhooks-dispatch has no healthy scrape targets runbook_url: https://runbooks.wekalo.example/alerts/WebhooksDispatchDown # 2% from OPS-2754; callers retry webhooks-dispatch, a few errors never reach a user - alert: WebhooksDispatchHighErrorRatio expr: | sum by (service) (rate(http_requests_total{service="webhooks-dispatch",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="webhooks-dispatch"}[5m])) > 0.02 for: 10m labels: severity: page team: integrations annotations: summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" runbook_url: https://runbooks.wekalo.example/alerts/WebhooksDispatchHighErrorRatio AF_EOF mkdir -p 'rules' cat > 'rules/legacy-billing.yml' <<'AF_EOF' # billing alerts from before the conventions in README.md. # Don't reformat in passing; move things out when you touch them for a reason. groups: # old dashboard records; the svc-overview board still reads these - name: billing-records rules: - record: job:http_requests:rate5m expr: sum by (job, service) (rate(http_requests_total{service="billing-svc"}[5m])) # keep: finance reads this one for the monthly availability report - record: job:http_errors:rate5m expr: sum by (job, service) (rate(http_requests_total{service="billing-svc",code=~"5.."}[5m])) - name: billing-svc rules: - alert: BillingSvcHighErrorRatio expr: sum by (service) (rate(http_requests_total{service="billing-svc",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="billing-svc"}[5m])) > 0.1 for: "10m" labels: {severity: page, team: billing} annotations: summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" runbook_url: https://runbooks.wekalo.example/alerts/BillingSvcHighErrorRatio - alert: BillingSvcLatencyHigh expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="billing-svc"}[5m]))) > 0.5 for: "10m" labels: {severity: warning, team: billing} annotations: summary: "{{ $labels.service }} p99 above 500ms" runbook_url: https://runbooks.wekalo.example/alerts/BillingSvcLatencyHigh - alert: BillingSvcLatencyHigh expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="billing-svc"}[5m]))) > 1 for: "10m" labels: {severity: critical, team: billing} annotations: summary: "{{ $labels.service }} p99 above 1s" runbook_url: https://runbooks.wekalo.example/alerts/BillingSvcLatencyHigh - alert: BillingSvcDbConnectionsHigh expr: max by (service) (db_pool_connections_active{service="billing-svc"} / db_pool_connections_max{service="billing-svc"}) > 0.8 for: "5m" labels: {severity: warning, team: billing} annotations: summary: "{{ $labels.service }} is using over 80% of its DB pool" runbook_url: https://runbooks.wekalo.example/alerts/BillingSvcDbConnectionsHigh - alert: BillingSvcDbConnectionsHigh expr: max by (service) (db_pool_connections_active{service="billing-svc"} / db_pool_connections_max{service="billing-svc"}) > 0.95 for: "5m" labels: {severity: critical, team: billing} annotations: summary: "{{ $labels.service }} DB pool nearly exhausted" runbook_url: https://runbooks.wekalo.example/alerts/BillingSvcDbConnectionsHigh # average over the targets: half of them gone is a ticket even while the rest carry the load - alert: BillingSvcTargetsHalfDown expr: avg by (service) (up{service="billing-svc"}) < 0.5 and on (service) count by (service) (up{service="billing-svc"}) >= 2 for: "10m" labels: {severity: ticket, team: billing} annotations: summary: "{{ $labels.service }} has lost half of its targets" runbook_url: https://runbooks.wekalo.example/alerts/BillingSvcTargetsHalfDown AF_EOF