I am running a PHP application in a Docker container and I would like the task ID to be included in the stream ID used in the logs sent to AWS Cloudwatch. How can I access it?
From my logs I can see that some of the errors include the system context which contains hopefully something like ECS_CONTAINER_METADATA_URI_V4
which includes the task id but this has to be parsed so hopefully there is a more Clean methods such as ENV[SOME_ENV_VAR]
may be referenced in the configuration file.
P粉4398045142024-03-31 11:35:45
You must make a request to the URI at ECS_CONTAINER_METADATA_URI_V4
and parse the response. There is no other way to access this data from inside the container.