DEV Community

Abdur Rahman
Abdur Rahman

Posted on

2

How to setup ECS logging with Cloudwatch

It is not uncommon for developers to be tasked with setting up monitoring for their applications. One of the most popular tools is Cloudwatch, which allows you to monitor your app's logs and metrics. This blog post will cover how to set up Cloudwatch log streaming from your ECS container - it's easy!

In your ECS task definition you can easily configure the log. I have added an example json to add logs as follows so that they are viewable in Cloudwatch:

{ 
   "taskDefinition":{
      "taskDefinitionArn":"ECR_name_goes_here",
      "containerDefinitions":[
         {
            "logConfiguration":{
               "logDriver":"awslogs",
               "options":{
                  "awslogs-group":"/test/group",
                  "awslogs-region":"us-west-1",
                  "awslogs-stream-prefix":"ecs"
               }
            }
         }
      ]
   }
}
Enter fullscreen mode Exit fullscreen mode

You'll find a list with all supported parameter for this link
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html

The logConfiguration object contains all settings for logging. After running the service under this task definition any STDOUT to system should be logged into Cloudwatch and can be checked from there as well!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up