Where are ECS Task logs being stored and for how long?

0

I am running an ECS cluster service powered by EC2. When I log onto the server, which was created with the ECS optimised AMI (AMI ID: ami-040d909ea4e56f8f3) - I can look into the docker logs for the Tasks I have running.

My log options in my Task Definition are:

 "logConfiguration": {
    "logDriver": "awslogs",
    "secretOptions": null,
    "options": {
      "awslogs-group": "logGroupName",
      "awslogs-region": "us-east-1",
      "awslogs-stream-prefix": "PrefixName"
    }
  }

As the logs are being forwarded to CloudWatch, they should be deleted from the instance - am I right? It doesn't make sense that an ECS optimised instance was created without this in mind.

My question simply is - where are these logs stored. Not the agent logs, as I can find the documentation for it, but the actual container logs. And when are they removed from the EC2 instance?

Sean
已提问 2 年前966 查看次数
1 回答
0
已接受的回答

The awslogs driver simply forwards your container STDOUT and STDERR log streams to CloudWatch Logs. It does not read from a specific location in your filesystem. Therefore, your application will need to be configured in such a way that the logs are emitted via the STDOUT and STDERR log streams.

If your application is also writing the logs to a custom location, you will have to perform log rotation to clean up these logs to avoid file system exhaustion.

profile pictureAWS
支持工程师
已回答 2 年前
  • Thanks for getting back to me. Highly appreciated.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则