- Newest
- Most votes
- Most comments
Hello,
I understand you want to read and print the CloudWatch logs in real time till the ECS run task is completed successfully.
To achieve real-time monitoring of CloudWatch logs during the execution of your ECS task, you can use the aws logs tail command in your shell script step. This command allows you to continuously stream logs from a CloudWatch log group.
Here's an example of how you can modify your script step:
aws logs tail "/ecs/your-log-group" --follow --filter-pattern "$TASK_ID" --format short
Explanation:
Run ECS Task: Execute your ECS task and capture the task ID from the output.
Determine Log Group: Identify the CloudWatch log group associated with your ECS task.
Tail Logs: Use the aws logs tail command to continuously stream logs from the specified log group. The --follow option ensures that new log events are continuously retrieved. The --filter-pattern option is used to filter logs based on the task ID or any other identifier relevant to your logs.
Remember to replace placeholders like your-log-group with your actual log group name.
Reference:
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/logs/tail.html
That being said, if you would like resource based troubleshooting, please raise a support case with AWS for further information and we will get back to you with on the support case.
Thank you!
Relevant content
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated a year ago
Just curious. Have you tried this yourself? The -follow option doesn't proceed without manual intervention, I think. I had tried it earlier and its gets stuck.