- Newest
- Most votes
- Most comments
The behavior you're observing is expected and is related to how Amazon ECS manages log streams for tasks. Each unique task instance creates its own log stream within the specified log group. The [$LATEST] followed by a unique identifier in the log stream name represents individual task runs.
Unfortunately, there isn't a direct way to consolidate all logs from a single day into one folder in CloudWatch Logs using just the ECS task definition configuration. The log stream creation is managed by ECS and is designed to separate logs for each task run for easier troubleshooting and management.
However, you can improve the organization of your logs by modifying the awslogs-stream-prefix in your task definition. Instead of just "ecs", you could use a more descriptive prefix that includes the date. For example:
"logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/node", "awslogs-create-group": "true", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "ecs-{date}" } }
While this won't consolidate all logs into a single folder, it will group them more logically by date, making it easier to find logs for a specific day.
If you need to analyze logs across multiple streams, you can use CloudWatch Logs Insights, which allows you to query across multiple log streams within a log group. This can help you view and analyze logs from multiple task runs together, even if they're in separate streams.
For more advanced log aggregation and analysis, you might consider using additional tools or services that can collect logs from multiple streams and consolidate them based on your specific requirements.
Sources
ECS task definition logging configuration | AWS re:Post
LogConfiguration - Amazon Elastic Container Service
These are not folders but as the agent says a log stream for each task.
A new one gets created if your ecs tasks dies or is restarted. Your container may be crashing several times so it restarts. Check the contents logs for why it crashed and the ECS cluster logs.
Relevant content
asked 2 years ago
asked 2 years ago
