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 Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay