本文介绍了如何从ECS集群获取所有日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一些AWS命令可以从ECS群集中获取所有服务/任务的日志?像这样:

Is there some AWS command get to get logs from all services/tasks from an ECS cluster? something like:

aws ecs logs --cluster dev

aws ecs describe-clusters --cluster dev logs

例如,必须有一些API才能检索此处UI中显示的日志:

for example, there must be some API to retrieve the logs that are shown in the UI here:

推荐答案

没有现成的选项可以从基于集群的所有服务中获取日志,因为evey容器在自己的空间中运行(EC2实例)

No there is no such out of the box option that takes logs from all service based on the cluster, as evey container running in their own space (EC2 instance).

因此可以尝试类似的选项,但是在此之前,您需要了解AWS ECS的日志记录机制.

So there can similar option that you can try, but before that, you need to understand the logging mechanism of AWS ECS.

logDriver

对于使用Fargate启动类型的任务,支持的日志驱动程序为awslogs, splunk, and awsfirelens.

For tasks using the Fargate launch type, the supported log drivers are awslogs, splunk, and awsfirelens.

对于使用EC2启动类型的任务,支持的日志驱动程序为awslogs, fluentd, gelf, json-file, journald, logentries, syslog, splunk, and awsfirelens.

For tasks using the EC2 launch type, the supported log drivers are awslogs, fluentd, gelf, json-file, journald, logentries, syslog, splunk, and awsfirelens.

因此,如果您在同一个ec2实例上运行多个容器,则syslog对您有意义.

So if you are running multiple container on same ec2 instance then syslog make sense for you.

系统日志记录驱动程序

但是最好的方法是对每个容器使用单个日志组.由于 syslog 在Fargate的情况下不起作用,因此最好将每个容器的日志组都使用.

But the best approach is to have a single log group against each container. as syslog is not working in case of fargate so better to go with log group per container.

这篇关于如何从ECS集群获取所有日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:44