AWS ECS-如何从ECS容器登录到CloudWatch? [英] AWS ECS - how to log to cloudwatch from ECS container?
问题描述
我有一个在ECS集群中运行给定任务的容器.我想将该任务的结果记录在cloudwatch中.
I have a container that runs a given task in an ECS cluster. I'd like to log the results of that task in cloudwatch.
我试图编辑容器以使用 awslogs
并设置以下参数:
I've attempted to edit the container to use awslogs
and set the following params:
-
awslogs-group
-
awslogs-region
当我尝试运行任务时,出现以下有用的错误:
When I attempt to run the task, I get the following helpful error:
是否存在一种经过验证的MVP方式来设置容器以登录到AWS中的cloudwatch?
Is there a proven MVP way of setting up containers to log to cloudwatch in AWS?
推荐答案
您应在"options"目录中添加另一个参数."logConfiguration"的在"containerDefinitions"内部像这样:
You should add another parameter in "options" of "logConfiguration" inside "containerDefinitions" like this:
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/<your-task-name>",
"awslogs-region": "ap-south-1",
"awslogs-stream-prefix": "ecs"
}
}
如果您想使用其他日志驱动程序,请参阅这些AWS文档和文档上的示例,用于记录部分此处.
If you want to use other log driver take a look at these examples on AWS docs and documentation for logging part here.
这篇关于AWS ECS-如何从ECS容器登录到CloudWatch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!