How to get all logs from an ECS cluster

☆樱花仙子☆ 提交于 2019-12-11 07:38:47

问题


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

aws ecs logs --cluster dev

or

aws ecs describe-clusters --cluster dev logs

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


回答1:


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).

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

logDriver

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.

For tasks using the Fargate launch type, the supported log drivers are awslogs, 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.

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

Syslog logging driver

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:

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.



来源:https://stackoverflow.com/questions/58001403/how-to-get-all-logs-from-an-ecs-cluster

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!