openenvforge's picture
3amBench v0.2.0
44084af verified
Raw History Blame Contribute Delete
19.9 kB
#!/bin/bash
# partial: even-indexed requirements + one plausible mistake
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
- matchers:
- team="economy"
receiver: slack-economy
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-economy
continue: true
- matchers:
- severity="ticket"
receiver: jira-economy
continue: true
- receiver: slack-economy
- matchers:
- team="player-platform"
receiver: slack-player-platform
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-player-platform
continue: true
- matchers:
- severity="ticket"
receiver: jira-player-platform
continue: true
- receiver: slack-player-platform
- matchers:
- team="social"
receiver: slack-social
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-social
continue: true
- matchers:
- severity="ticket"
receiver: jira-social
continue: true
- receiver: slack-social
# matchmaking: still on the old match syntax
- match:
team: matchmaking
receiver: slack-matchmaking
routes:
- match_re:
severity: page|critical
receiver: pagerduty-matchmaking
continue: true
- match:
severity: ticket
receiver: jira-matchmaking
continue: true
- receiver: slack-matchmaking
- matchers:
- team="live-ops"
receiver: slack-live-ops
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-live-ops
continue: true
- matchers:
- severity="ticket"
receiver: jira-live-ops
continue: true
- receiver: slack-live-ops
# live-ops services from before team labels were everywhere
- matchers:
- service=~"asset-indexer"
receiver: slack-live-ops
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-live-ops
continue: true
- receiver: slack-live-ops
- matchers:
- team="telemetry"
receiver: slack-telemetry
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-telemetry
continue: true
- matchers:
- severity="ticket"
receiver: jira-telemetry
continue: true
- receiver: slack-telemetry
# teams below route alerts from the platform and data Prometheus servers
- 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
# platform wanted tickets in Slack as well as Jira (OPS-2251)
- 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="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
# tickets and warnings per pod in Slack, so the channel shows which pod; pages group per service above
- receiver: slack-database-reliability
group_by: [alertname, pod, service]
- matchers:
- team="security-ops"
receiver: slack-security-ops
group_wait: 10s
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-security-ops
continue: true
- matchers:
- severity="ticket"
receiver: jira-security-ops
continue: true
- receiver: slack-security-ops
- 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="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
# network asked for hourly repeats while something is still firing
- matchers:
- team="network"
receiver: slack-network
repeat_interval: 1h
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-network
continue: true
- matchers:
- severity="ticket"
receiver: jira-network
continue: true
- receiver: slack-network
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-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.cobaltline.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.cobaltline.example/hooks/database_reliability
- name: pagerduty-economy
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/economy
- name: slack-economy
slack_configs:
- channel: "#economy-alerts"
send_resolved: true
- name: jira-economy
webhook_configs:
- url: https://jira-bridge.cobaltline.example/hooks/economy
- 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.cobaltline.example/hooks/edge
- name: pagerduty-live-ops
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/live-ops
- name: slack-live-ops
slack_configs:
- channel: "#live-ops-alerts"
send_resolved: true
- name: jira-live-ops
webhook_configs:
- url: https://jira-bridge.cobaltline.example/hooks/live_ops
- name: pagerduty-matchmaking
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/matchmaking
- name: slack-matchmaking
slack_configs:
- channel: "#matchmaking-alerts"
send_resolved: true
- name: jira-matchmaking
webhook_configs:
- url: https://jira-bridge.cobaltline.example/hooks/matchmaking
- 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.cobaltline.example/hooks/messaging
- 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.cobaltline.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.cobaltline.example/hooks/platform
- name: pagerduty-player-platform
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/player-platform
- name: slack-player-platform
slack_configs:
- channel: "#player-platform-alerts"
send_resolved: true
- name: jira-player-platform
webhook_configs:
- url: https://jira-bridge.cobaltline.example/hooks/player_platform
- 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.cobaltline.example/hooks/security_ops
- name: pagerduty-social
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/social
- name: slack-social
slack_configs:
- channel: "#social-alerts"
send_resolved: true
- name: jira-social
webhook_configs:
- url: https://jira-bridge.cobaltline.example/hooks/social
- name: pagerduty-telemetry
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/telemetry
- name: slack-telemetry
slack_configs:
- channel: "#telemetry-alerts"
send_resolved: true
- name: jira-telemetry
webhook_configs:
- url: https://jira-bridge.cobaltline.example/hooks/telemetry
# 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]
AF_EOF
mkdir -p 'rules'
cat > 'rules/legacy-economy.yml' <<'AF_EOF'
# economy 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: economy-records
rules:
# keep: finance reads this one for the monthly availability report
- record: job:http_requests:rate5m
expr: sum by (job, service) (rate(http_requests_total{service="store-api"}[5m]))
- record: job:http_errors:rate5m
expr: sum by (job, service) (rate(http_requests_total{service="store-api",code=~"5.."}[5m]))
- name: store-api
rules:
- alert: StoreApiHighErrorRatio
expr: sum by (service) (rate(http_requests_total{service="store-api",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="store-api"}[5m])) > 0.1
for: "10m"
labels: {severity: page, team: economy}
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.cobaltline.example/alerts/StoreApiHighErrorRatio
- alert: StoreApiTrafficBelowFloor
expr: sum by (service) (rate(http_requests_total{service="store-api"}[5m])) < 5 and on (service) sum by (service) (up{service="store-api"}) > 0
for: "5m"
labels: {severity: page, team: economy}
annotations:
summary: "{{ $labels.service }} is serving under its traffic floor with its pods up"
runbook_url: https://runbooks.cobaltline.example/alerts/StoreApiTrafficBelowFloor
# p99 across the whole service; the per-route view is on the team board
- alert: StoreApiLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="store-api"}[5m]))) > 0.5
for: "10m"
labels: {severity: warning, team: economy}
annotations:
summary: "{{ $labels.service }} p99 above 500ms"
runbook_url: https://runbooks.cobaltline.example/alerts/StoreApiLatencyHigh
- alert: StoreApiLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="store-api"}[5m]))) > 1
for: "10m"
labels: {severity: critical, team: economy}
annotations:
summary: "{{ $labels.service }} p99 above 1s"
runbook_url: https://runbooks.cobaltline.example/alerts/StoreApiLatencyHigh
- alert: StoreApiDbConnectionsHigh
expr: max by (service) (db_pool_connections_active{service="store-api"} / db_pool_connections_max{service="store-api"}) > 0.8
for: "5m"
labels: {severity: warning, team: economy}
annotations:
summary: "{{ $labels.service }} is using over 80% of its DB pool"
runbook_url: https://runbooks.cobaltline.example/alerts/StoreApiDbConnectionsHigh
- alert: StoreApiDbConnectionsHigh
expr: max by (service) (db_pool_connections_active{service="store-api"} / db_pool_connections_max{service="store-api"}) > 0.95
for: "5m"
labels: {severity: critical, team: economy}
annotations:
summary: "{{ $labels.service }} DB pool nearly exhausted"
runbook_url: https://runbooks.cobaltline.example/alerts/StoreApiDbConnectionsHigh
AF_EOF
mkdir -p 'rules'
cat > 'rules/slo-profile-svc.yml' <<'AF_EOF'
groups:
- name: slo-profile-svc
rules:
- alert: ProfileSvcErrorBudgetBurnFast
expr: |
slo:sli_error:ratio_rate1h{service="profile-svc"} > (3.36 * 0.001)
and slo:sli_error:ratio_rate5m{service="profile-svc"} > (3.36 * 0.001)
for: 2m
labels:
severity: page
team: player-platform
slo: profile-svc-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget fast"
runbook_url: https://runbooks.cobaltline.example/alerts/ProfileSvcErrorBudgetBurnFast
- alert: ProfileSvcErrorBudgetBurnSlow
expr: |
slo:sli_error:ratio_rate6h{service="profile-svc"} > (6 * 0.001)
and slo:sli_error:ratio_rate30m{service="profile-svc"} > (6 * 0.001)
for: 15m
labels:
severity: ticket
team: player-platform
slo: profile-svc-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget steadily"
runbook_url: https://runbooks.cobaltline.example/alerts/ProfileSvcErrorBudgetBurnSlow
AF_EOF
mkdir -p 'rules'
cat > 'rules/social-rules.yaml' <<'AF_EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: social-rules
namespace: monitoring
labels:
role: alert-rules
spec:
groups:
- name: leaderboard-svc
rules:
- alert: LeaderboardSvcDown
expr: |
sum by (service) (up{service="leaderboard-svc"}) == 0
or absent(up{service="leaderboard-svc"})
for: 3m
labels:
severity: page
team: social
annotations:
summary: leaderboard-svc has no healthy scrape targets
runbook_url: https://runbooks.cobaltline.example/alerts/LeaderboardSvcDown
- alert: LeaderboardSvcHighErrorRatio
expr: |
sum by (service) (rate(http_requests_total{service="leaderboard-svc",code=~"5.."}[5m]))
/ sum by (service) (rate(http_requests_total{service="leaderboard-svc"}[5m])) > 0.05
for: 10m
labels:
severity: page
team: social
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.cobaltline.example/alerts/LeaderboardSvcHighErrorRatio
- alert: LeaderboardSvcErrorBudgetBurnFast
expr: |
slo:sli_error:ratio_rate1h{service="leaderboard-svc"} > (14.4 * 0.0005)
and slo:sli_error:ratio_rate5m{service="leaderboard-svc"} > (14.4 * 0.0005)
for: 2m
labels:
severity: page
team: social
slo: leaderboard-svc-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget fast"
runbook_url: https://runbooks.cobaltline.example/alerts/LeaderboardSvcErrorBudgetBurnFast
- alert: LeaderboardSvcErrorBudgetBurnSlow
expr: |
slo:sli_error:ratio_rate6h{service="leaderboard-svc"} > (6 * 0.0005)
and slo:sli_error:ratio_rate30m{service="leaderboard-svc"} > (6 * 0.0005)
for: 15m
labels:
severity: ticket
team: social
slo: leaderboard-svc-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget steadily"
runbook_url: https://runbooks.cobaltline.example/alerts/LeaderboardSvcErrorBudgetBurnSlow
- name: chat-gw
rules:
- alert: ChatGwDown
expr: |
sum by (service) (up{service="chat-gw"}) == 0
or absent(up{service="chat-gw"})
for: 3m
labels:
severity: page
team: social
annotations:
summary: chat-gw has no healthy scrape targets
runbook_url: https://runbooks.cobaltline.example/alerts/ChatGwDown
- alert: ChatGwHighErrorRatio
expr: |
sum by (service) (rate(http_requests_total{service="chat-gw",code=~"5.."}[5m]))
/ sum by (service) (rate(http_requests_total{service="chat-gw"}[5m])) > 0.1
for: 10m
labels:
severity: page
team: social
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.cobaltline.example/alerts/ChatGwHighErrorRatio
# factors from the SRE workbook's multiwindow table, don't tune per service
- alert: ChatGwErrorBudgetBurnFast
expr: |
slo:sli_error:ratio_rate1h{service="chat-gw"} > (14.4 * 0.001)
and slo:sli_error:ratio_rate5m{service="chat-gw"} > (14.4 * 0.001)
for: 2m
labels:
severity: page
team: social
slo: chat-gw-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget fast"
runbook_url: https://runbooks.cobaltline.example/alerts/ChatGwErrorBudgetBurnFast
- alert: ChatGwErrorBudgetBurnSlow
expr: |
slo:sli_error:ratio_rate6h{service="chat-gw"} > (6 * 0.001)
and slo:sli_error:ratio_rate30m{service="chat-gw"} > (6 * 0.001)
for: 15m
labels:
severity: ticket
team: social
slo: chat-gw-availability
annotations:
summary: "{{ $labels.service }} is spending its error budget steadily"
runbook_url: https://runbooks.cobaltline.example/alerts/ChatGwErrorBudgetBurnSlow
# average the pods: they all run with the same limit, so the mean is what we size it by
- alert: ChatGwCpuThrottled
expr: |
avg by (service) (rate(container_cpu_cfs_throttled_periods_total{service="chat-gw",container="chat-gw"}[5m]) / rate(container_cpu_cfs_periods_total{service="chat-gw",container="chat-gw"}[5m])) > 0.25
for: 30m
labels:
severity: ticket
team: social
annotations:
summary: "{{ $labels.service }} pods spend over a quarter of their CPU periods throttled"
runbook_url: https://runbooks.cobaltline.example/alerts/ChatGwCpuThrottled
AF_EOF