2
votes

Is it possible to dynamically set values in AWS ECS task definitions? For example. I have the following volume definition.

"volumes": [
    {
        "host": {
            "sourcePath": "/tmp/logs/registrations"
        },
        "name": "logs"
    }
],

I would like do do something like /tmp/logs/<container_id>.

I am trying to do this because I have multiple containers running the same app. I need to mount each containers log directory for a sumologic collector. The problem is if the directories aren't namespaced by container then the mounts will conflict.

2

2 Answers

2
votes

Cloudwatch logs is another option if saving to the file system is not a requirement.

If you are using the ECS optimized AMI it's already configured and all you need to do is turn it on in the container task definition:

http://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html

You would also need to configure log groups or log streams for each container.

1
votes

Is saving logs to the file system a hard requirement? If not, Sumo Logic has a pretty good article about another option: Update On Logging With Docker.

You run the Sumo Logic Collector for Docker in one container and your application in another. You configure Docker to send logs from your application container to the Sumo Logic collector. This is built into Docker, so your application shouldn't need to change. The collector container will then send those logs to Sumo Logic.

I've seen this pattern called the sidecar, in case you're looking for other examples of it.