Sign inSign up

cybergavin/ecs-metalens

By cybergavin

•Updated over 1 year ago

ECS MetaLens is a lightweight Flask web application designed to display task metadata.

Image
Monitoring & observability
0

1.2K

cybergavin/ecs-metalens repository overview

⁠ECS MetaLens

⁠Overview

ECS MetaLens is a lightweight Flask web application designed to display metadata about the Amazon ECS task and container it is running in. The application fetches details from the ECS task metadata endpoint and presents them in a human-readable HTML table.

⁠Features

  • Retrieves ECS cluster name, task ID, and availability zone.
  • Displays metadata for all containers in the ECS task, including:
    • Container name
    • Image name
    • IPv4 addresses
    • Identification of the current running container
  • Provides a simple web UI for visualization.

⁠Prerequisites

  • Docker
  • Amazon ECS cluster (Fargate or EC2-backed)
  • Task metadata endpoint enabled (automatically available in ECS tasks)

⁠Deploying to ECS

⁠1. Create an ECS Cluster

Use the following AWS CLI command to create an ECS cluster with default networking:

aws ecs create-cluster --cluster-name my-cluster
⁠2. Create an ECS Task Definition

Use the following AWS CLI command to create an ECS task definition for Fargate:

aws ecs register-task-definition   --family ecs-metalens-task   --network-mode awsvpc   --container-definitions \
'[{ \
    "name": "ecs-metalens", \
    "image": "cybergavin/ecs-metalens:latest", \
    "portMappings": [{"containerPort": 7777, "hostPort": 7777}], \
    "essential": true \
  }]'   --requires-compatibilities FARGATE --cpu 256 --memory 512
⁠3. Launch an ECS Task

Use the following AWS CLI command to launch an ECS task for the registered task definition on the ECS cluster:

aws ecs run-task --cluster my-cluster \
--task-definition ecs-metalens-task \
--launch-type FARGATE \
--network-configuration 'awsvpcConfiguration={subnets=["<subnet-id>"],assignPublicIp="ENABLED"}'

where, <subnet-id> = subnet ID for one of the default subnets.

NOTE: If you are accessing the ECS service behind an ALB, then don't enable public IP.

⁠Accessing the Application

Once the container is running on ECS, access the application via the public IP or ALB associated with the ECS service:

http://<ecs_service_public_ip>:7777

⁠Error Handling

  • If metadata fetching fails, the application returns an HTTP 500 error with diagnostic information.
  • Missing or malformed metadata fields are also reported in the response.

⁠License

This project is released under the MIT License.

Tag summary

Content type

Image

Digest

sha256:5a8fa858a…

Size

19.4 MB

Last updated

over 1 year ago

docker pull cybergavin/ecs-metalens