Search code examples
laravelamazon-cloudwatchamazon-ecsamazon-cloudwatchlogsaws-fargate

CloudWatch single Log Stream for Fargate


I have an ECS Fargate application which log are saved in cloudwatch using awslog driver.

Logging works very well, the only annoying thing is that each container creates a different log stream, which name is, as explained on the documentation here

prefix-name/container-name/ecs-task-id

I make an extensive use of autoscaling, creating a lot of tasks, which in turn produce a lot of log streams.

I was wondering if it's possible to have all the logs into the same log stream, that would help me a lot but it looks like it's not possible off the shelf. How could I achieve my goal ?


Solution

  • This is not a solution to your usecase, but a workaround you could use is to just search on your log group instead of going into your task-id. You can also use range queries on a log group so this ends up providing pretty much the same thing as going into the specific log stream of the each task-id. Each line of the log in the log group also has a link to the task specific logs stream.

    Another thing you could try to do is using elastic search to maintain your logs. Querying on elastic search is extremely easy (it comes built in with kibana which is a pretty powerful off the shelf filtering tool.