newrelic / node-newrelic

New Relic Node.js agent code base. Developers are welcome to create pull requests here, please see our contributing guidelines. For New Relic technical support, please go to http://support.newrelic.com.
Apache License 2.0
963 stars 391 forks source link

Add support for fetching container identifier in ECS Fargate #2276

Closed jsumners-nr closed 4 weeks ago

jsumners-nr commented 1 month ago

When an application is running inside of a Docker container, on a Linux guest, our agent is able to retrieve an identifier for that container via cgroups that are populated by Docker. However, when the host is AWS ECS Fargate, those cgroups are not present within the guest. Instead, a metadata API that is available to the guest should be consulted.

We need to:

  1. Update the following function to utilize this metadata endpoint if the cgroups are not available: https://github.com/newrelic/node-newrelic/blob/07a841b9acf0a0dcb1a495c5cb0ee8f77e283fc9/lib/utilization/docker-info.js#L62-L88
  2. We should first attempt to look for the API endpoint through the URI available in the ECS_CONTAINER_METADATA_URI_V4 environment variable. If that environment variable does not exist, try the ECS_CONTAINER_METADATA_URI environment variable. If neither exist, exit with a failure as the function currently does.
workato-integration[bot] commented 1 month ago

https://new-relic.atlassian.net/browse/NR-280818