openenvforge's picture
3amBench v0.2.0
44084af verified
Raw History Blame Contribute Delete
19 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="network-planning"
receiver: slack-network-planning
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-network-planning
continue: true
- matchers:
- severity="ticket"
receiver: jira-network-planning
continue: true
- receiver: slack-network-planning
# routing: still on the old match syntax
- match:
team: routing
receiver: slack-routing
routes:
- match_re:
severity: page|critical
receiver: pagerduty-routing
continue: true
- match:
severity: ticket
receiver: jira-routing
continue: true
- receiver: slack-routing
- matchers:
- team="tracking"
receiver: slack-tracking
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-tracking
continue: true
- matchers:
- severity="ticket"
receiver: jira-tracking
continue: true
- receiver: slack-tracking
- matchers:
- team="carrier-integrations"
receiver: slack-carrier-integrations
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-carrier-integrations
continue: true
- matchers:
- severity="ticket"
receiver: jira-carrier-integrations
continue: true
- receiver: slack-carrier-integrations
- matchers:
- team="dispatch"
receiver: slack-dispatch
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-dispatch
continue: true
- matchers:
- severity="ticket"
receiver: jira-dispatch
continue: true
- receiver: slack-dispatch
# teams below route alerts from the platform and data Prometheus servers
- matchers:
- team="platform"
receiver: slack-platform
group_wait: 10s
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
- 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
- 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
# 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
# messaging wanted tickets in Slack as well as Jira (LOG-2861)
- matchers:
- team="messaging"
receiver: slack-messaging
routes:
- matchers:
- severity=~"page|critical"
receiver: pagerduty-messaging
continue: true
- matchers:
- severity="ticket"
receiver: jira-messaging
continue: true
# tickets and warnings per pod in Slack, so the channel shows which pod; pages group per service above
- receiver: slack-messaging
group_by: [alertname, pod, service]
- 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
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-carrier-integrations
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/carrier-integrations
- name: slack-carrier-integrations
slack_configs:
- channel: "#carrier-integrations-alerts"
send_resolved: true
- name: jira-carrier-integrations
webhook_configs:
- url: https://jira-bridge.int.fahrwerk.example/hooks/carrier_integrations
- 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.int.fahrwerk.example/hooks/database_reliability
- name: pagerduty-dispatch
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/dispatch
- name: slack-dispatch
slack_configs:
- channel: "#dispatch-alerts"
send_resolved: true
- name: jira-dispatch
webhook_configs:
- url: https://jira-bridge.int.fahrwerk.example/hooks/dispatch
- 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.int.fahrwerk.example/hooks/edge
- 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.int.fahrwerk.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.int.fahrwerk.example/hooks/ml_platform
- name: pagerduty-network-planning
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/network-planning
- name: slack-network-planning
slack_configs:
- channel: "#network-planning-alerts"
send_resolved: true
- name: jira-network-planning
webhook_configs:
- url: https://jira-bridge.int.fahrwerk.example/hooks/network_planning
- 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.int.fahrwerk.example/hooks/platform
- name: pagerduty-routing
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/routing
- name: slack-routing
slack_configs:
- channel: "#routing-alerts"
send_resolved: true
- name: jira-routing
webhook_configs:
- url: https://jira-bridge.int.fahrwerk.example/hooks/routing
- 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.int.fahrwerk.example/hooks/security_ops
# routing key rotated in LOG-2782
- 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.int.fahrwerk.example/hooks/storage
- name: pagerduty-tracking
pagerduty_configs:
- routing_key_file: /etc/alertmanager/secrets/pagerduty/tracking
- name: slack-tracking
slack_configs:
- channel: "#tracking-alerts"
send_resolved: true
- name: jira-tracking
webhook_configs:
- url: https://jira-bridge.int.fahrwerk.example/hooks/tracking
# kept for the platform Prometheus until its config is cleaned up
- name: slack-ops-legacy
slack_configs:
- channel: "#ops-alerts-legacy"
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-dispatch.yml' <<'AF_EOF'
# dispatch 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: dispatch-records
rules:
- record: job:http_requests:rate5m
expr: sum by (job, service) (rate(http_requests_total{service="dispatch-gw"}[5m]))
- record: job:http_errors:rate5m
expr: sum by (job, service) (rate(http_requests_total{service="dispatch-gw",code=~"5.."}[5m]))
# running total for the 'errors since deploy' stat on svc-overview
- record: service:http_errors:sum
expr: sum by (service) (http_requests_total{code=~"5.."})
- name: dispatch-gw
rules:
- alert: DispatchGwHighErrorRatio
expr: sum by (service) (rate(http_requests_total{service="dispatch-gw",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="dispatch-gw"}[5m])) > 0.02
for: "10m"
labels: {severity: page, team: dispatch}
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/DispatchGwHighErrorRatio
- alert: DispatchGwLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="dispatch-gw"}[5m]))) > 0.5
for: "10m"
labels: {severity: warning, team: dispatch}
annotations:
summary: "{{ $labels.service }} p99 above 500ms"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/DispatchGwLatencyHigh
- alert: DispatchGwLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="dispatch-gw"}[5m]))) > 1
for: "10m"
labels: {severity: critical, team: dispatch}
annotations:
summary: "{{ $labels.service }} p99 above 1s"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/DispatchGwLatencyHigh
- alert: DbClientConnectionErrors
expr: rate(db_client_connection_errors_total{service="dispatch-gw"}[2m]) > 0.5
for: "2m"
labels: {severity: page, team: dispatch}
annotations:
summary: "{{ $labels.pod }} can't get database connections"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/DbClientConnectionErrors
- alert: DispatchGwErrorBurst
expr: rate(service:http_errors:sum{service="dispatch-gw"}[5m]) > 1
for: "30m"
labels: {severity: page, team: dispatch}
annotations:
summary: "{{ $labels.service }} is returning more than 1 errors/s"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/DispatchGwErrorBurst
AF_EOF
mkdir -p 'rules'
cat > 'rules/legacy-tracking.yml' <<'AF_EOF'
# tracking 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: tracking-records
rules:
- record: job:grpc_calls:rate5m
expr: sum by (job, service) (rate(grpc_server_handled_total{service="eta-svc"}[5m]))
- record: job:grpc_errors:rate5m
expr: sum by (job, service) (rate(grpc_server_handled_total{service="eta-svc",grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m]))
- record: job:http_requests:rate5m
expr: sum by (job, service) (rate(http_requests_total{service=~"label-printer|tracking-api"}[5m]))
- record: job:http_errors:rate5m
expr: sum by (job, service) (rate(http_requests_total{service=~"label-printer|tracking-api",code=~"5.."}[5m]))
- name: label-printer
rules:
# threshold agreed with tracking in LOG-1665
- alert: LabelPrinterHighErrorRatio
expr: sum by (service) (rate(http_requests_total{service="label-printer",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="label-printer"}[5m])) > 0.02
for: "10m"
labels: {severity: page, team: tracking}
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/LabelPrinterHighErrorRatio
- alert: LabelPrinterLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="label-printer"}[5m]))) > 0.5
for: "10m"
labels: {severity: warning, team: tracking}
annotations:
summary: "{{ $labels.service }} p99 above 500ms"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/LabelPrinterLatencyHigh
# TODO(2024) move to a latency SLO once we have one
- alert: LabelPrinterLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="label-printer"}[5m]))) > 1
for: "10m"
labels: {severity: critical, team: tracking}
annotations:
summary: "{{ $labels.service }} p99 above 1s"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/LabelPrinterLatencyHigh
- alert: DbClientConnectionErrors
expr: rate(db_client_connection_errors_total{service="label-printer"}[2m]) > 0.5
for: "2m"
labels: {severity: page, team: tracking}
annotations:
summary: "{{ $labels.pod }} can't get database connections"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/DbClientConnectionErrors
- name: tracking-api
rules:
- alert: TrackingApiHighErrorRatio
expr: sum by (service) (rate(http_requests_total{service="tracking-api",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="tracking-api"}[5m])) > 0.05
for: "10m"
labels: {severity: page, team: tracking}
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/TrackingApiHighErrorRatio
- alert: TrackingApiLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="tracking-api"}[5m]))) > 0.5
for: "10m"
labels: {severity: warning, team: tracking}
annotations:
summary: "{{ $labels.service }} p99 above 500ms"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/TrackingApiLatencyHigh
- alert: TrackingApiLatencyHigh
expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="tracking-api"}[5m]))) > 1
for: "10m"
labels: {severity: critical, team: tracking}
annotations:
summary: "{{ $labels.service }} p99 above 1s"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/TrackingApiLatencyHigh
- alert: TrackingApiDbConnectionsHigh
expr: max by (service) (db_pool_connections_active{service="tracking-api"} / db_pool_connections_max{service="tracking-api"}) > 0.8
for: "5m"
labels: {severity: warning, team: tracking}
annotations:
summary: "{{ $labels.service }} is using over 80% of its DB pool"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/TrackingApiDbConnectionsHigh
- alert: TrackingApiDbConnectionsHigh
expr: max by (service) (db_pool_connections_active{service="tracking-api"} / db_pool_connections_max{service="tracking-api"}) > 0.95
for: "5m"
labels: {severity: critical, team: tracking}
annotations:
summary: "{{ $labels.service }} DB pool nearly exhausted"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/TrackingApiDbConnectionsHigh
- alert: DbClientConnectionErrors
expr: rate(db_client_connection_errors_total{service="tracking-api"}[2m]) > 0.5
for: "2m"
labels: {severity: page, team: tracking}
annotations:
summary: "{{ $labels.pod }} can't get database connections"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/DbClientConnectionErrors
# average over the targets: half of them gone is a ticket even while the rest carry the load
- alert: TrackingApiTargetsHalfDown
expr: avg by (service) (up{service="tracking-api"}) < 0.5 and on (service) count by (service) (up{service="tracking-api"}) >= 2
for: "10m"
labels: {severity: ticket, team: tracking}
annotations:
summary: "{{ $labels.service }} has lost half of its targets"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/TrackingApiTargetsHalfDown
- name: eta-svc
rules:
- alert: EtaSvcHighErrorRatio
expr: sum by (service) (rate(grpc_server_handled_total{service="eta-svc",grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m])) / sum by (service) (rate(grpc_server_handled_total{service="eta-svc"}[5m])) > 0.05
for: "10m"
labels: {severity: page, team: tracking}
annotations:
summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests"
runbook_url: https://runbooks.int.fahrwerk.example/alerts/EtaSvcHighErrorRatio
AF_EOF