Download tasks/afx-e1-s07/solution/solve.sh from openenvforge/3ambench: direct link, hf CLI and curl.
- Browser
- Download file 18.7 kB
-
https://huggingface.co/datasets/openenvforge/3ambench/resolve/main/tasks/afx-e1-s07/solution/solve.sh
- Command line
-
hf download hf://datasets/openenvforge/3ambench/tasks/afx-e1-s07/solution/solve.sh
-
curl -L -o solve.sh https://huggingface.co/datasets/openenvforge/3ambench/resolve/main/tasks/afx-e1-s07/solution/solve.sh
18.7 kB
| # oracle: rewrites changed files to the oracle state | |
| set -euo pipefail | |
| cd /workspace/monitoring | |
| mkdir -p 'rules' | |
| cat > 'rules/disk.yml' <<'AF_EOF' | |
| # host disks (infra) | |
| groups: | |
| - name: disk | |
| rules: | |
| - alert: HostDiskAlmostFull | |
| expr: node_filesystem_avail_bytes{fstype!~"tmpfs|overlay"} / node_filesystem_size_bytes < 0.1 | |
| for: "5m" | |
| labels: {severity: warning, team: infra} | |
| annotations: | |
| summary: "{{ $labels.instance }} {{ $labels.mountpoint }} is under 10% free" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/HostDiskAlmostFull | |
| 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: | |
| - 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: | |
| # 5xx only; 429s are the rate limiter doing its job | |
| - 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.hexbloom.example/alerts/StoreApiHighErrorRatio | |
| - 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.hexbloom.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.hexbloom.example/alerts/StoreApiLatencyHigh | |
| - alert: ReplicationLagHigh | |
| expr: max by (service) (pg_replication_lag_seconds{service="store-api"}) > 30 | |
| for: "10m" | |
| labels: {severity: page, team: economy} | |
| annotations: | |
| summary: "{{ $labels.service }} replica is behind the primary" | |
| description: Replication lag is {{ $value | humanize }}s. | |
| runbook_url: https://runbooks.hexbloom.example/alerts/ReplicationLagHigh | |
| AF_EOF | |
| mkdir -p 'rules' | |
| cat > 'rules/legacy-matchmaking.yml' <<'AF_EOF' | |
| # matchmaking 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: matchmaking-records | |
| rules: | |
| - record: job:grpc_calls:rate5m | |
| expr: sum by (job, service) (rate(grpc_server_handled_total{service="matchmaker"}[5m])) | |
| # keep: finance reads this one for the monthly availability report | |
| - record: job:grpc_errors:rate5m | |
| expr: sum by (job, service) (rate(grpc_server_handled_total{service="matchmaker",grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m])) | |
| - record: job:http_requests:rate5m | |
| expr: sum by (job, service) (rate(http_requests_total{service=~"lobby-api|telemetry-ingest|lobby-worker"}[5m])) | |
| - record: job:http_errors:rate5m | |
| expr: sum by (job, service) (rate(http_requests_total{service=~"lobby-api|telemetry-ingest|lobby-worker",code=~"5.."}[5m])) | |
| - name: lobby-api | |
| rules: | |
| - alert: LobbyApiHighErrorRatio | |
| expr: sum by (service) (rate(http_requests_total{service="lobby-api",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="lobby-api"}[5m])) > 0.1 | |
| for: "10m" | |
| labels: {severity: page, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiHighErrorRatio | |
| - alert: LobbyApiLatencyHigh | |
| expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="lobby-api"}[5m]))) > 0.5 | |
| for: "10m" | |
| labels: {severity: warning, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} p99 above 500ms" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiLatencyHigh | |
| - alert: LobbyApiLatencyHigh | |
| expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="lobby-api"}[5m]))) > 1 | |
| for: "10m" | |
| labels: {severity: critical, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} p99 above 1s" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiLatencyHigh | |
| - alert: LobbyApiDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="lobby-api"} / db_pool_connections_max{service="lobby-api"}) > 0.8 | |
| for: "5m" | |
| labels: {severity: warning, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} is using over 80% of its DB pool" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiDbConnectionsHigh | |
| - alert: LobbyApiDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="lobby-api"} / db_pool_connections_max{service="lobby-api"}) > 0.95 | |
| for: "5m" | |
| labels: {severity: critical, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} DB pool nearly exhausted" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiDbConnectionsHigh | |
| - name: telemetry-ingest | |
| rules: | |
| # threshold agreed with matchmaking in LIVE-1375 | |
| - alert: TelemetryIngestHighErrorRatio | |
| expr: sum by (service) (rate(http_requests_total{service="telemetry-ingest",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="telemetry-ingest"}[5m])) > 0.02 | |
| for: "10m" | |
| labels: {severity: page, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/TelemetryIngestHighErrorRatio | |
| - alert: TelemetryIngestQueueBacklogHigh | |
| expr: max by (service) (work_queue_depth{service="telemetry-ingest"}) > 5000 | |
| for: "15m" | |
| labels: {severity: page, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} has more than 5000 jobs waiting" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/TelemetryIngestQueueBacklogHigh | |
| - name: matchmaker | |
| rules: | |
| # threshold agreed with matchmaking in LIVE-1798 | |
| - alert: MatchmakerHighErrorRatio | |
| expr: sum by (service) (rate(grpc_server_handled_total{service="matchmaker",grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m])) / sum by (service) (rate(grpc_server_handled_total{service="matchmaker"}[5m])) > 0.1 | |
| for: "10m" | |
| labels: {severity: page, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/MatchmakerHighErrorRatio | |
| - name: lobby-worker | |
| rules: | |
| - alert: LobbyWorkerHighErrorRatio | |
| expr: sum by (service) (rate(http_requests_total{service="lobby-worker",code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total{service="lobby-worker"}[5m])) > 0.1 | |
| for: "10m" | |
| labels: {severity: page, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyWorkerHighErrorRatio | |
| - alert: LobbyWorkerDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="lobby-worker"} / db_pool_connections_max{service="lobby-worker"}) > 0.8 | |
| for: "5m" | |
| labels: {severity: warning, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} is using over 80% of its DB pool" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyWorkerDbConnectionsHigh | |
| - alert: LobbyWorkerDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="lobby-worker"} / db_pool_connections_max{service="lobby-worker"}) > 0.95 | |
| for: "5m" | |
| labels: {severity: critical, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} DB pool nearly exhausted" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyWorkerDbConnectionsHigh | |
| - alert: LobbyWorkerExportLate | |
| expr: time() - max by (service) (export_last_success_timestamp_seconds{service="lobby-worker"}) > 3 * 3600 | |
| for: "30m" | |
| labels: {severity: ticket, team: matchmaking} | |
| annotations: | |
| summary: "{{ $labels.service }} hasn't finished an export in over 3 hours" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyWorkerExportLate | |
| AF_EOF | |
| mkdir -p 'rules' | |
| cat > 'rules/legacy-social.yml' <<'AF_EOF' | |
| # social 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: social-records | |
| rules: | |
| - record: job:http_requests:rate5m | |
| expr: sum by (job, service) (rate(http_requests_total{service=~"leaderboard-svc|chat-gw"}[5m])) | |
| - record: job:http_errors:rate5m | |
| expr: sum by (job, service) (rate(http_requests_total{service=~"leaderboard-svc|chat-gw",code=~"5.."}[5m])) | |
| - name: leaderboard-svc | |
| rules: | |
| # threshold agreed with social in LIVE-1357 | |
| - 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.1 | |
| for: "10m" | |
| labels: {severity: page, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LeaderboardSvcHighErrorRatio | |
| - alert: LeaderboardSvcLatencyHigh | |
| expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="leaderboard-svc"}[5m]))) > 0.5 | |
| for: "10m" | |
| labels: {severity: warning, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} p99 above 500ms" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LeaderboardSvcLatencyHigh | |
| - alert: LeaderboardSvcLatencyHigh | |
| expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="leaderboard-svc"}[5m]))) > 1 | |
| for: "10m" | |
| labels: {severity: critical, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} p99 above 1s" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LeaderboardSvcLatencyHigh | |
| - alert: LeaderboardSvcDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="leaderboard-svc"} / db_pool_connections_max{service="leaderboard-svc"}) > 0.8 | |
| for: "5m" | |
| labels: {severity: warning, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} is using over 80% of its DB pool" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LeaderboardSvcDbConnectionsHigh | |
| - alert: LeaderboardSvcDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="leaderboard-svc"} / db_pool_connections_max{service="leaderboard-svc"}) > 0.95 | |
| for: "5m" | |
| labels: {severity: critical, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} DB pool nearly exhausted" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LeaderboardSvcDbConnectionsHigh | |
| - name: chat-gw | |
| rules: | |
| - 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.02 | |
| for: "10m" | |
| labels: {severity: page, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} is failing {{ $value | humanizePercentage }} of requests" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/ChatGwHighErrorRatio | |
| - alert: ChatGwLatencyHigh | |
| expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="chat-gw"}[5m]))) > 0.5 | |
| for: "10m" | |
| labels: {severity: warning, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} p99 above 500ms" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/ChatGwLatencyHigh | |
| - alert: ChatGwLatencyHigh | |
| expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket{service="chat-gw"}[5m]))) > 1 | |
| for: "10m" | |
| labels: {severity: critical, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} p99 above 1s" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/ChatGwLatencyHigh | |
| - alert: ChatGwDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="chat-gw"} / db_pool_connections_max{service="chat-gw"}) > 0.8 | |
| for: "5m" | |
| labels: {severity: warning, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} is using over 80% of its DB pool" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/ChatGwDbConnectionsHigh | |
| - alert: ChatGwDbConnectionsHigh | |
| expr: max by (service) (db_pool_connections_active{service="chat-gw"} / db_pool_connections_max{service="chat-gw"}) > 0.95 | |
| for: "5m" | |
| labels: {severity: critical, team: social} | |
| annotations: | |
| summary: "{{ $labels.service }} DB pool nearly exhausted" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/ChatGwDbConnectionsHigh | |
| # 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.hexbloom.example/alerts/ChatGwCpuThrottled | |
| AF_EOF | |
| mkdir -p 'rules' | |
| cat > 'rules/service-health.yml' <<'AF_EOF' | |
| # One Down alert per service. See README, Service health. | |
| groups: | |
| - name: service-health | |
| rules: | |
| - alert: LobbyApiDown | |
| expr: | | |
| sum by (service) (up{service="lobby-api"}) == 0 | |
| or absent(up{service="lobby-api"}) | |
| for: 3m | |
| labels: | |
| severity: page | |
| team: matchmaking | |
| annotations: | |
| summary: lobby-api has no healthy scrape targets | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiDown | |
| - 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.hexbloom.example/alerts/LeaderboardSvcDown | |
| - alert: TelemetryIngestDown | |
| expr: | | |
| sum by (service) (up{service="telemetry-ingest"}) == 0 | |
| or absent(up{service="telemetry-ingest"}) | |
| for: 3m | |
| labels: | |
| severity: page | |
| team: matchmaking | |
| annotations: | |
| summary: telemetry-ingest has no healthy scrape targets | |
| runbook_url: https://runbooks.hexbloom.example/alerts/TelemetryIngestDown | |
| - alert: MatchmakerDown | |
| expr: | | |
| sum by (service) (up{service="matchmaker"}) == 0 | |
| or absent(up{service="matchmaker"}) | |
| for: 3m | |
| labels: | |
| severity: page | |
| team: matchmaking | |
| annotations: | |
| summary: matchmaker has no healthy scrape targets | |
| runbook_url: https://runbooks.hexbloom.example/alerts/MatchmakerDown | |
| - alert: AssetIndexerDown | |
| expr: | | |
| sum by (service) (up{service="asset-indexer"}) == 0 | |
| or absent(up{service="asset-indexer"}) | |
| for: 3m | |
| labels: | |
| severity: page | |
| team: live-ops | |
| annotations: | |
| summary: asset-indexer has no healthy scrape targets | |
| runbook_url: https://runbooks.hexbloom.example/alerts/AssetIndexerDown | |
| - 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.hexbloom.example/alerts/ChatGwDown | |
| # for: 3m so a rolling restart doesn't page; store-api cycles one pod at a time | |
| - alert: StoreApiDown | |
| expr: | | |
| sum by (service) (up{service="store-api"}) == 0 | |
| or absent(up{service="store-api"}) | |
| for: 3m | |
| labels: | |
| severity: page | |
| team: economy | |
| annotations: | |
| summary: store-api has no healthy scrape targets | |
| runbook_url: https://runbooks.hexbloom.example/alerts/StoreApiDown | |
| - alert: LobbyWorkerDown | |
| expr: | | |
| sum by (service) (up{service="lobby-worker"}) == 0 | |
| or absent(up{service="lobby-worker"}) | |
| for: 3m | |
| labels: | |
| severity: page | |
| team: matchmaking | |
| annotations: | |
| summary: lobby-worker has no healthy scrape targets | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyWorkerDown | |
| AF_EOF | |
| mkdir -p 'rules' | |
| cat > 'rules/slo-lobby-api.yml' <<'AF_EOF' | |
| groups: | |
| - name: slo-lobby-api | |
| rules: | |
| - alert: LobbyApiErrorBudgetBurnFast | |
| expr: | | |
| slo:sli_error:ratio_rate1h{service="lobby-api"} > (3.36 * 0.01) | |
| and slo:sli_error:ratio_rate5m{service="lobby-api"} > (3.36 * 0.01) | |
| for: 2m | |
| labels: | |
| severity: page | |
| team: matchmaking | |
| slo: lobby-api-availability | |
| annotations: | |
| summary: "{{ $labels.service }} is spending its error budget fast" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiErrorBudgetBurnFast | |
| - alert: LobbyApiErrorBudgetBurnSlow | |
| expr: | | |
| slo:sli_error:ratio_rate6h{service="lobby-api"} > (1.4 * 0.01) | |
| and slo:sli_error:ratio_rate30m{service="lobby-api"} > (1.4 * 0.01) | |
| for: 15m | |
| labels: | |
| severity: ticket | |
| team: matchmaking | |
| slo: lobby-api-availability | |
| annotations: | |
| summary: "{{ $labels.service }} is spending its error budget steadily" | |
| runbook_url: https://runbooks.hexbloom.example/alerts/LobbyApiErrorBudgetBurnSlow | |
| AF_EOF | |