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"
}
}
}
]
}
}
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!
Top comments (0)