4

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:

enter image description here

1 Answers1

3

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: enter image description here

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.

enter image description here

Adiii
  • 54,482
  • 7
  • 145
  • 148
  • I updated the OP, there really is no API to retrieve the logs that are available from the AWS web console? –  Sep 18 '19 at 23:03
  • 1
    thanks again, just as a concept, I am playing with this if you have any thoughts: https://stackoverflow.com/questions/58001832/how-bad-is-it-to-pipe-process-to-consumer-in-entrypoint –  Sep 18 '19 at 23:23