openenvforge's picture
3amBench v0.2.0
44084af verified
Raw History Blame Contribute Delete
25.3 kB
#!/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
smtp_smarthost: smtp.tessellate.example:587
smtp_from: alertmanager@tessellate.example
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
# reporting: still on the old match syntax
- match:
team: reporting
receiver: slack-reporting
routes:
- match_re:
severity: page|critical
receiver: pagerduty-reporting
continue: true
- match:
severity: ticket
receiver: jira-reporting
continue: true
- receiver: slack-reporting
- 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="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="search"
receiver: slack-search
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-search
continue: true
- matchers:
- severity="ticket"
receiver: jira-search
continue: true
# tickets and warnings per pod in Slack, so the channel shows which pod; pages group per service above
- receiver: slack-search
group_by: [alertname, pod, service]
- 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
# core-api services from before team labels were everywhere
- matchers:
- service=~"files-api|tenant-api"
receiver: slack-core-api
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-core-api
continue: true
- receiver: slack-core-api
- matchers:
- team="identity"
receiver: slack-identity
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-identity
continue: true
- matchers:
- severity="ticket"
receiver: jira-identity
continue: true
- receiver: slack-identity
# teams below route alerts from the platform and data Prometheus servers
- 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="ml-platform"
receiver: slack-ml-platform
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="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="build-infra"
receiver: slack-build-infra
group_wait: 10s
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-build-infra
continue: true
- matchers:
- severity="ticket"
receiver: jira-build-infra
continue: true
- receiver: slack-build-infra
- 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
- 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
# security-ops asked for hourly repeats while something is still firing
- matchers:
- team="security-ops"
receiver: slack-security-ops
repeat_interval: 1h
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-security-ops
continue: true
- matchers:
- severity="ticket"
receiver: jira-security-ops
continue: true
- receiver: slack-security-ops
# data-platform wanted tickets in Slack as well as Jira (OBS-2816)
- 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
- receiver: slack-data-platform
- 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
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
# routing key rotated in OBS-1120
- 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.tessellate.example/hooks/billing
- name: pagerduty-build-infra
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/build-infra
- name: slack-build-infra
slack_configs:
- channel: "#build-infra-alerts"
send_resolved: true
- name: jira-build-infra
webhook_configs:
- url: https://jira-bridge.tessellate.example/hooks/build_infra
- 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.tessellate.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.tessellate.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.tessellate.example/hooks/database_reliability
- 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.tessellate.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.tessellate.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.tessellate.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.tessellate.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.tessellate.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.tessellate.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.tessellate.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.tessellate.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.tessellate.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.tessellate.example/hooks/storage
# unused since 2024, the SMTP relay it points at is gone
- name: email-oncall
email_configs:
- to: oncall@tessellate.example
send_resolved: false
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="TenantApiDown"
target_matchers:
- alertname=~"TenantApiErrorBudgetBurnFast|TenantApiErrorBudgetBurnSlow|TenantApiHighErrorRatio"
equal: [service]
AF_EOF
mkdir -p 'rules'
cat > 'rules/core-api-rules.yaml' <<'AF_EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: core-api-rules
namespace: monitoring
labels:
role: alert-rules
spec:
groups:
- name: files-api
rules:
- alert: FilesApiDown
expr: |
sum by (service) (up{service="files-api"}) == 0
or absent(up{service="files-api"})
for: 3m
labels:
severity: page
team: core-api
annotations:
summary: files-api has no healthy scrape targets
runbook_url: https://runbooks.tessellate.example/alerts/FilesApiDown
- alert: FilesApiHighErrorRatio
expr: |
sum by (service) (rate(http_requests_total{service="files-api",code=~"5.."}[5m]))
/ sum by (service) (rate(http_requests_total{service="files-api"}[5m])) > 0.05
for: 10m
labels:
severity: page
team: core-api
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.tessellate.example/alerts/FilesApiHighErrorRatio
- alert: FilesApiErrorBudgetBurnFast
expr: |
slo:sli_error:ratio_rate1h{service="files-api"} > (14.4 * 0.0005)
and slo:sli_error:ratio_rate5m{service="files-api"} > (14.4 * 0.0005)
for: 2m
labels:
severity: page
team: core-api
slo: files-api-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget fast"
runbook_url: https://runbooks.tessellate.example/alerts/FilesApiErrorBudgetBurnFast
# ticket, not page: at this rate there are days of budget left, not hours
- alert: FilesApiErrorBudgetBurnSlow
expr: |
slo:sli_error:ratio_rate6h{service="files-api"} > (6 * 0.0005)
and slo:sli_error:ratio_rate30m{service="files-api"} > (6 * 0.0005)
for: 15m
labels:
severity: ticket
team: core-api
slo: files-api-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget steadily"
runbook_url: https://runbooks.tessellate.example/alerts/FilesApiErrorBudgetBurnSlow
- alert: DbClientConnectionErrors
expr: |
rate(db_client_connection_errors_total{service="files-api"}[2m]) > 0.5
for: 2m
labels:
severity: page
team: core-api
annotations:
summary: "{{ $labels.pod }} can't get database connections"
runbook_url: https://runbooks.tessellate.example/alerts/DbClientConnectionErrors
- name: tenant-api
rules:
- alert: TenantApiDown
expr: |
sum by (service) (up{service="tenant-api"}) == 0
or absent(up{service="tenant-api"})
for: 3m
labels:
severity: page
team: core-api
annotations:
summary: tenant-api has no healthy scrape targets
runbook_url: https://runbooks.tessellate.example/alerts/TenantApiDown
- alert: TenantApiHighErrorRatio
expr: |
sum by (service) (rate(http_requests_total{service="tenant-api",code=~"5.."}[5m]))
/ sum by (service) (rate(http_requests_total{service="tenant-api"}[5m])) > 0.1
for: 10m
labels:
severity: page
team: core-api
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.tessellate.example/alerts/TenantApiHighErrorRatio
- alert: TenantApiErrorBudgetBurnFast
expr: |
slo:sli_error:ratio_rate1h{service="tenant-api"} > (14.4 * 0.01)
and slo:sli_error:ratio_rate5m{service="tenant-api"} > (14.4 * 0.01)
for: 2m
labels:
severity: page
team: core-api
slo: tenant-api-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget fast"
runbook_url: https://runbooks.tessellate.example/alerts/TenantApiErrorBudgetBurnFast
- alert: TenantApiErrorBudgetBurnSlow
expr: |
slo:sli_error:ratio_rate6h{service="tenant-api"} > (6 * 0.01)
and slo:sli_error:ratio_rate30m{service="tenant-api"} > (6 * 0.01)
for: 15m
labels:
severity: ticket
team: core-api
slo: tenant-api-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget steadily"
runbook_url: https://runbooks.tessellate.example/alerts/TenantApiErrorBudgetBurnSlow
- alert: DbClientConnectionErrors
expr: |
rate(db_client_connection_errors_total{service="tenant-api"}[2m]) > 0.5
for: 2m
labels:
severity: page
team: core-api
annotations:
summary: "{{ $labels.pod }} can't get database connections"
runbook_url: https://runbooks.tessellate.example/alerts/DbClientConnectionErrors
- name: sso-gw
rules:
- alert: SsoGwDown
expr: |
sum by (service) (up{service="sso-gw"}) == 0
or absent(up{service="sso-gw"})
for: 3m
labels:
severity: page
team: identity
annotations:
summary: sso-gw has no healthy scrape targets
runbook_url: https://runbooks.tessellate.example/alerts/SsoGwDown
- alert: SsoGwHighErrorRatio
expr: |
sum by (service) (rate(http_requests_total{service="sso-gw",code=~"5.."}[5m]))
/ sum by (service) (rate(http_requests_total{service="sso-gw"}[5m])) > 0.05
for: 10m
labels:
severity: page
team: identity
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.tessellate.example/alerts/SsoGwHighErrorRatio
- alert: SsoGwErrorBudgetBurnFast
expr: |
slo:sli_error:ratio_rate1h{service="sso-gw"} > (14.4 * 0.005)
and slo:sli_error:ratio_rate5m{service="sso-gw"} > (14.4 * 0.005)
for: 2m
labels:
severity: page
team: identity
slo: sso-gw-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget fast"
runbook_url: https://runbooks.tessellate.example/alerts/SsoGwErrorBudgetBurnFast
- alert: SsoGwErrorBudgetBurnSlow
expr: |
slo:sli_error:ratio_rate6h{service="sso-gw"} > (6 * 0.005)
and slo:sli_error:ratio_rate30m{service="sso-gw"} > (6 * 0.005)
for: 15m
labels:
severity: ticket
team: identity
slo: sso-gw-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget steadily"
runbook_url: https://runbooks.tessellate.example/alerts/SsoGwErrorBudgetBurnSlow
- alert: DbClientConnectionErrors
expr: |
rate(db_client_connection_errors_total{service="sso-gw"}[2m]) > 0.5
for: 2m
labels:
severity: page
team: identity
annotations:
summary: "{{ $labels.pod }} can't get database connections"
runbook_url: https://runbooks.tessellate.example/alerts/DbClientConnectionErrors
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:
# threshold agreed with billing in OBS-1830
- 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.05
for: "10m"
labels: {severity: page, team: billing}
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.tessellate.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.tessellate.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.tessellate.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.tessellate.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.tessellate.example/alerts/BillingSvcDbConnectionsHigh
AF_EOF
mkdir -p 'rules'
cat > 'rules/legacy-reporting.yml' <<'AF_EOF'
# reporting 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: reporting-records
rules:
- record: job:http_requests:rate5m
expr: sum by (job, service) (rate(http_requests_total{service="reports-worker"}[5m]))
- record: job:http_errors:rate5m
expr: sum by (job, service) (rate(http_requests_total{service="reports-worker",code=~"5.."}[5m]))
- name: reports-worker
rules:
- 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.1
for: "10m"
labels: {severity: page, team: reporting}
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.tessellate.example/alerts/ReportsWorkerHighErrorRatio
- alert: ReportsWorkerLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="reports-worker"}[5m]))) > 0.5
for: "10m"
labels: {severity: warning, team: reporting}
annotations:
summary: "{{ $labels.service }} p99 above 500ms"
runbook_url: https://runbooks.tessellate.example/alerts/ReportsWorkerLatencyHigh
- alert: ReportsWorkerLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="reports-worker"}[5m]))) > 1
for: "10m"
labels: {severity: critical, team: reporting}
annotations:
summary: "{{ $labels.service }} p99 above 1s"
runbook_url: https://runbooks.tessellate.example/alerts/ReportsWorkerLatencyHigh
AF_EOF
mkdir -p 'rules'
cat > 'rules/slo-billing-svc.yml' <<'AF_EOF'
groups:
- name: slo-billing-svc
rules:
- alert: BillingSvcErrorBudgetBurnFast
expr: |
slo:sli_error:ratio_rate1h{service="billing-svc"} > (3.36 * 0.001)
and slo:sli_error:ratio_rate5m{service="billing-svc"} > (3.36 * 0.001)
for: 2m
labels:
severity: page
team: billing
slo: billing-svc-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget fast"
runbook_url: https://runbooks.tessellate.example/alerts/BillingSvcErrorBudgetBurnFast
- alert: BillingSvcErrorBudgetBurnSlow
expr: |
slo:sli_error:ratio_rate6h{service="billing-svc"} > (1.4 * 0.001)
and slo:sli_error:ratio_rate30m{service="billing-svc"} > (1.4 * 0.001)
for: 15m
labels:
severity: ticket
team: billing
slo: billing-svc-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget steadily"
runbook_url: https://runbooks.tessellate.example/alerts/BillingSvcErrorBudgetBurnSlow
AF_EOF