Repository navigation
feat(monitoring): alert on ECS services that cannot start tasks - #160
Open
Alexanderamiri wants to merge 2 commits into
Open
Alexanderamiri wants to merge 2 commits into
Alexanderamiri wants to merge 2 commits into
Conversation
EventBridge rule on SERVICE_TASK_START_IMPAIRED for the platform cluster, routed through javabin-security to #javabin-infra-alerts. slack-alert formats it and dedups once per service per UTC day in the alert-dedup table. A crash-looping service otherwise burns Fargate starts, image pulls and AWS Config items unnoticed (testteam-platform-test-app, ~80 attempts/day). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Terraform Plan🚧 Changes detected — Plan: 2 to add, 2 to change, 0 to destroy. Plan outputLLM ReviewRisk: 🟢 LOW Plan updates two Lambda functions' code (source hash change only) and adds a CloudWatch Event rule and SNS target to alert on ECS task start impairment in the platform cluster; 0 destroys.
|
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Terraform Plan🚧 Changes detected — Plan: 2 to add, 2 to change, 0 to destroy. Plan outputLLM ReviewRisk: 🟢 LOW Plan updates two existing Lambda functions (code-only source_code_hash change) and adds an EventBridge rule and target that forward ECS task-start-impaired events from the javabin-platform cluster to the javabin-security SNS topic; nothing is destroyed.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
testteam-platform-test-apphas been crash-looping for weeks with desired=1 and running=0, because of aCannotPullContainerError(its ECR repo is empty). That is about 80 failed task starts a day, and nobody noticed. Each attempt creates and deletes a Fargate ENI, which AWS Config records. This was the main driver of about $29/mo in Config charges found in the 2026-10 cost audit. PR #159 reduces the Config side. This PR makes the crash loop itself visible.What
monitoring/main.tf: new EventBridge rulejavabin-ecs-task-start-impaired. It matchessource=aws.ecs,detail-type=ECS Service ActionandeventName=SERVICE_TASK_START_IMPAIRED, for thejavabin-platformcluster only (legacy CDK clusters are excluded). The target is thejavabin-securitySNS topic, whose policy already allowsevents.amazonaws.com. slack-alert sends non-finding events from that topic to #javabin-infra-alerts. I chose that channel over the cost channel because this is an operational problem.slack_alert/handler.py:format_ecs_service_impairedformatter, routed before the generic EventBridge branch. Without it, the event would fall through to the IAM-change formatter.javabin-alert-deduptable, keyed per service ARN per UTC day. ECS keeps emitting the event while the service is impaired.terraform/lambda-src/tests/test_slack_alert_ecs.pychecks the formatting, once-per-day dedup per service, and that other ECS service actions are ignored.docs/lambda-functions.md.Expected plan
2 to add:
aws_cloudwatch_event_rule.ecs_task_start_impairedandaws_cloudwatch_event_target.ecs_task_start_impaired_sns. 1 in-place update: the slack-alert Lambda code. No IAM changes, because slack-alert already has GetItem/PutItem on the dedup table.How verified
python3 -m unittest discover -s terraform/lambda-src/tests(67 OK, 3 new) and-s scripts/testspass.terraform fmt -recursive -check, thenterraform init -backend=falseandterraform validatepass.Follow-ups
testteam-platform-test-app. Scale it to 0 or push its image.monitoring/main.tf, but in different blocks.🤖 Generated with Claude Code