【发布时间】:2018-12-02 21:07:12
【问题描述】:
我正在为此撕毁我的头发。 这是我的设置:
- EC2 实例上的 ECS 容器包含一个
- 运行的 ECS 任务定义
- 带有 python 脚本的 Docker 实例记录到标准错误
我看到创建了 ECS 任务的 Cloudwatch 日志组,但没有出现我打印到 stderr 的任何内容。
我的 ECS 容器具有默认的 ecsInstanceRole。 ecsInstanceRole 的 AmazonEC2ContainerServiceforEC2Role 策略如下:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:CreateCluster",
"ecs:DeregisterContainerInstance",
"ecs:DiscoverPollEndpoint",
"ecs:Poll",
"ecs:RegisterContainerInstance",
"ecs:StartTelemetrySession",
"ecs:UpdateContainerInstancesState",
"ecs:Submit*",
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
任务定义
{
"containerDefinitions": [
{
"dnsSearchDomains": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "torres",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "torres"
}
},
"command": [
"sleep",
"infinity"
],
"cpu": 100,
"mountPoints": [
{
"readOnly": null,
"containerPath": "/mnt/efs",
"sourceVolume": "efs"
}
],
"memoryReservation": 512,
"image": "X.dkr.ecr.us-west-2.amazonaws.com/torres-docker:latest",
"interactive": true,
"essential": true,
"pseudoTerminal": true,
"readonlyRootFilesystem": false,
"privileged": false,
"name": "torres"
}
],
"family": "torres",
"volumes": [
{
"name": "efs",
"host": {
"sourcePath": "/mnt/efs"
}
}
]
}
【问题讨论】:
-
您能否也分享您的任务任务定义详细信息?您是否确保 ECS 代理启用了 awslogs 驱动程序。
ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","awslogs"]。另外,请确保您的应用程序(python)正在登录到控制台。 -
感谢伊姆兰的回复。我添加了任务定义。该应用程序正在登录到控制台,ECS 代理是 1.22 版,因此它不需要按照这里的配置 docs.aws.amazon.com/AmazonECS/latest/developerguide/…
标签: amazon-cloudwatch amazon-ecs amazon-cloudwatchlogs