Skip to main content

ECS Doctor 🩺

CI PyPI version PyPI downloads License: MIT Python 3.12+

One command to diagnose why your ECS service is failing.

ECS troubleshooting means jumping between the ECS console, CloudWatch Logs, ALB target groups, and task definitions — manually correlating signals across every incident. ECS Doctor pulls all of those signals together and gives you a single confidence-scored root-cause report with a suggested fix, in under a second.

pipx install ecs-doctor
ecs-doctor diagnose --cluster prod --service payments

ECS Doctor demo output


What it checks

ECS Doctor runs 7 parallel diagnostic checks across the AWS APIs that matter:

Check AWS APIs What it catches
Service events ecs:DescribeServices Why your deployment stalled, rolled back, or never reached steady state
Stop reasons ecs:ListTasks, ecs:DescribeTasks Why your container stopped — OOM, bad image, missing secrets, startup failures, and more
CloudWatch Logs logs:GetLogEvents Crash signatures across Python, Java, Go, Node.js, and 5 other runtimes — without you grepping
ALB health elasticloadbalancing:DescribeTargetHealth, elasticloadbalancing:DescribeTargetGroups Why your load balancer is dropping traffic — including health-check path mismatches
Metrics cloudwatch:GetMetricData CPU, memory, ALB 5xx, and unhealthy host count
Task config ecs:DescribeTaskDefinition Misconfiguration in your task definition or service that will silently break deployments
Network ec2:Describe* Connectivity issues blocking your tasks from reaching AWS services or the internet

All findings are scored, ranked by confidence, and collapsed into a single root cause.


Installation

# Recommended — isolated install
pipx install ecs-doctor

# Terminal only
pip install ecs-doctor

# With web UI
pip install "ecs-doctor[web]"

# With interactive arrow-key browser
pip install "ecs-doctor[interactive]"

# Everything
pip install "ecs-doctor[web,interactive]"

CLI Usage

# Diagnose a service
ecs-doctor diagnose --cluster my-cluster --service my-service

# Omit --service to pick interactively from the cluster
ecs-doctor diagnose --cluster my-cluster

# Use a named AWS profile
ecs-doctor diagnose --cluster my-cluster --service my-service --profile staging

# Specify region
ecs-doctor diagnose --cluster my-cluster --service my-service --region eu-west-1

# Machine-readable JSON (pipe to jq, Slack bots, incident tooling)
ecs-doctor diagnose --cluster my-cluster --service my-service --json

# Stream live logs from running tasks (Ctrl+C to stop)
ecs-doctor diagnose --cluster my-cluster --service my-service --stream-logs

# Skip CloudWatch metrics (faster, fewer IAM permissions needed)
ecs-doctor diagnose --cluster my-cluster --service my-service --no-metrics

# Deep probes: ECR image / Secrets Manager existence + FilterLogEvents (slower)
ecs-doctor diagnose --cluster my-cluster --service my-service --deep

# Interactive wizard — guides you through account → region → cluster → service
ecs-doctor browse

Options reference

ecs-doctor diagnose [OPTIONS]

  --cluster TEXT      ECS cluster name or ARN  [required]
  --service TEXT      ECS service name (omit to pick interactively)
  --region TEXT       AWS region (overrides profile / env default)
  --profile TEXT      AWS named profile from ~/.aws/credentials
  --json              Machine-readable JSON output
  --stream-logs       Stream live logs from running tasks
  --no-metrics        Skip CloudWatch metrics
  --no-config         Skip task definition config panel
  --deep              Probe ECR/Secrets/SSM existence after pull/init failures

Web UI

pip install "ecs-doctor[web]"
ecs-doctor serve          # opens at http://localhost:8080

The web interface provides the same diagnosis in a browser — useful for teams who prefer a point-and-click workflow or want to share results on screen.

Key features:

  • Profile → Cluster → Service dropdowns auto-populated from your ~/.aws/credentials — no typing required
  • Tabbed results — Diagnosis, Metrics, Config, Live Logs in separate tabs so you never scroll through a wall of output
  • Metrics tab — CPU and memory shown as color-coded progress bars (green / amber / red by threshold)
  • Live Logs tab — streams CloudWatch log events directly in the browser via Server-Sent Events; Start / Stop with a status indicator

Authentication

ECS Doctor follows the standard boto3 credential chain — the same one used by the AWS CLI:

Method How
Environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
Named profile --profile my-profile or AWS_PROFILE=my-profile
ECS task role Automatic when running inside Fargate / ECS
EC2 instance role Automatic when running on EC2
Web Identity / OIDC Automatic via AWS_WEB_IDENTITY_TOKEN_FILE (GitHub Actions, EKS)

If credentials cannot be resolved, the tool exits with a clear message listing all supported methods.


IAM Permissions

Minimum policy for a full scan:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ecs:DescribeServices", "ecs:DescribeTasks", "ecs:DescribeTaskDefinition",
        "ecs:DescribeClusters", "ecs:ListTasks", "ecs:ListClusters", "ecs:ListServices"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": ["logs:GetLogEvents", "logs:FilterLogEvents"],
      "Resource": "arn:aws:logs:*:*:log-group:/ecs/*:*"
    },
    {
      "Effect": "Allow",
      "Action": ["cloudwatch:GetMetricData"],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": ["elasticloadbalancing:DescribeTargetHealth", "elasticloadbalancing:DescribeTargetGroups"],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "ec2:DescribeSecurityGroups", "ec2:DescribeSubnets",
        "ec2:DescribeRouteTables", "ec2:DescribeNatGateways",
        "ec2:DescribeNetworkInterfaces", "ec2:DescribeVpcEndpoints",
        "ec2:DescribeNetworkAcls"
      ],
      "Resource": "*"
    },
    { "Effect": "Allow", "Action": ["sts:GetCallerIdentity"], "Resource": "*" }
  ]
}

--deep also needs:

{
  "Effect": "Allow",
  "Action": [
    "ecr:DescribeImages",
    "secretsmanager:DescribeSecret",
    "ssm:GetParameter"
  ],
  "Resource": "*"
}

Tip: If you only have ECS + Logs + ELB permissions, pass --no-metrics. ECS Doctor skips any check it lacks permissions for and tells you exactly which IAM action and resource ARN you'd need to add.


JSON output

Pass --json to get a machine-readable report — useful for CI pipelines, Slack bots, PagerDuty runbooks, or any custom incident tooling:

ecs-doctor diagnose --cluster prod --service payments --json | jq .root_cause
{
  "cause": "Container is being OOM-killed (out of memory)",
  "confidence": 0.97,
  "suggested_fix": "Increase the container memory reservation in the task definition...",
  "evidence": [...]
}

Contributing

Contributions are welcome — bug reports, new diagnosers, additional log patterns, and documentation improvements.

git clone https://github.com/PraveenLuke/ecs-doctor
cd ecs-doctor
pip install -e ".[dev,web,interactive]"
pytest tests/ -v

To add a new diagnoser: create ecs_doctor/diagnosers/my_check.py, add FindingType entries to models.py, add a hypothesis to aggregator.py, wire it into engine.py, and add tests under tests/.


License

MIT — see LICENSE.


Built by @PraveenLuke (Praveen Rajkoilraj). If ECS Doctor saved you time during an incident, consider giving the repo a ⭐.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecs_doctor-0.5.0.tar.gz (85.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ecs_doctor-0.5.0-py3-none-any.whl (66.3 kB view details)

Uploaded Python 3

File details

Details for the file ecs_doctor-0.5.0.tar.gz.

File metadata

  • Download URL: ecs_doctor-0.5.0.tar.gz
  • Upload date:
  • Size: 85.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ecs_doctor-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0601adb7f95a794970b6038dbc041bc3ddbd735c1cc8db3ff5114c98f328d090
MD5 6ef38ba54b8700418979965e66f28d29
BLAKE2b-256 8d098181730f2ea66d612de4a2b204c5dc736c5cf340073738033056a065d9d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ecs_doctor-0.5.0.tar.gz:

Publisher: release.yml on PraveenLuke/ecs-doctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ecs_doctor-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ecs_doctor-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 66.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ecs_doctor-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d44210ae8357c2f5f51b6a810456cb58e87f16f3332f1888fed439c0dc0f7666
MD5 9aa03b72529de3456b69d7816427589b
BLAKE2b-256 36020a3c5be94864122e1804a3b3742f12644660f1b3e0a2b8e3f5884cd9a540

See more details on using hashes here.

Provenance

The following attestation bundles were made for ecs_doctor-0.5.0-py3-none-any.whl:

Publisher: release.yml on PraveenLuke/ecs-doctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page