如何从ECS集群获取所有日志 [英] How to get all logs from an ECS cluster

查看:210
本文介绍了如何从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

用于容器的日志驱动程序.列出的有效值 此参数是Amazon ECS容器代理可以执行的日志驱动程序 默认情况下与之通信.

The log driver to use for the container. The valid values listed for this parameter are log drivers that the Amazon ECS container agent can communicate with by default.

对于使用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日志记录驱动程序将日志路由到syslog服务器.系统日志 协议使用原始字符串作为日志消息并支持有限 元数据集. syslog消息必须使用特定格式 有效的方式.接收者可以从有效消息中提取 以下信息:

The syslog logging driver routes logs to a syslog server. The syslog protocol uses a raw string as the log message and supports a limited set of metadata. The syslog message must be formatted in a specific way to be valid. From a valid message, the receiver can extract the following information:

但是最好的方法是对每个容器使用单个日志组.由于 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集群获取所有日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆