Get the task id as a log-opt tag in non Cloudwatch logs logging driver
- Dominant language
- Shell
- Stars
- 5.4k
- Forks
- 334
- PR merge metrics
- No merged PRs in 30d
Description
### Summary
It would be useful to be able to use the task id in a logging drivers tagged output.
### Description
I'm starting to look at shipping logs to somewhere other than Cloudwatch logs (was useful to get a PoC up and running but Cloudwatch logs suffers massively from being difficult to view across streams, something that is 10x worse with containers) but I'd still like to be able to see the task id that is logging if possible.
I was planning on using a fluentd log driver and tag the logs with the service name but it strikes me that it would be near perfect to use the ECS generated container name.
Looking at the output of `docker ps` and https://github.com/aws/amazon-ecs-agent/blob/master/agent/engine/docker_task_engine.go#L639 I can see the autogenerated name for the container has the task definition family + version which is useful but then oddly has a random hex string at the end.
I can see you need a source of randomness here in case a service schedules multiple tasks on to the same container instance but it would be more useful if this was just the task id which is already unique.
The task struct already contains the `Arn` which has the task id so I'd suggest parsing it out of that.
Contributor guide
Research direction
The request points to agent/engine/docker_task_engine.go around line 639 and to the task struct's Arn; inspect how container names and non-CloudWatch logging tags are generated. Check how the fluentd driver receives its tag, and define done as exposing the ECS task ID in tags for non-CloudWatch logging drivers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker
- Domain
- cloud, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100