Contents:


Overview

Monitoring and logging are essential for tracking the health and performance of your application and infrastructure.
In this workshop, we will use:

  • Amazon CloudWatch Logs to store and analyze logs from containers.
  • CloudWatch Container Insights to monitor CPU, Memory, Network, and Storage usage.
  • CloudWatch Alarms to receive notifications when issues occur.

Enable Amazon CloudWatch Logs

  1. Go to ECS ConsoleCluster → Select your service.
  2. In the Task Definition, check the log driver configuration:
    • Select awslogs as the log driver.
    • Log Group name: /ecs/fargate-workshop
    • Region: us-east-1 (or your chosen AWS region).
  3. Save and redeploy the service. Amazon CloudWatch Logs

Enable Container Insights

  1. Go to CloudWatch ConsoleContainer Insights.
  2. Select Enable for your ECS Cluster.
  3. Container Insights will automatically collect:
    • CPUUtilization
    • MemoryUtilization
    • NetworkRxBytes / NetworkTxBytes
    • StorageReadBytes / StorageWriteBytes

Viewing Logs and Metrics

  1. Open CloudWatch ConsoleLogs → Select the Log Group /ecs/fargate-workshop.
  2. View container logs (stdout, stderr).
  3. Go to CloudWatch Metrics → ECS → Cluster Metrics to see CPU, RAM, and Network statistics.
  4. Filter by specific services or tasks for detailed analysis.

Integrating Alerts (Alarms)

  1. Go to CloudWatch ConsoleAlarmsCreate alarm.
  2. Select a metric, for example: ECS/ContainerInsights – CPUUtilization.
  3. Set a threshold, e.g., CPU > 80% for 5 minutes.
  4. Choose an SNS Topic to receive email notifications when the alarm is triggered.
  5. Save and activate the alarm.

Expected Outcome:

  • You can view logs for each container to debug issues.
  • Monitor application performance in real-time.
  • Receive notifications when the system encounters issues or exceeds resource thresholds.