Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fetching container identifier in ECS Fargate #2276

Closed
jsumners-nr opened this issue Jun 13, 2024 · 1 comment · Fixed by #2292
Closed

Add support for fetching container identifier in ECS Fargate #2276

jsumners-nr opened this issue Jun 13, 2024 · 1 comment · Fixed by #2292
Assignees

Comments

@jsumners-nr
Copy link
Contributor

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:
    function fetchDockerVendorInfo(agent, callback) {
    if (!agent.config.utilization || !agent.config.utilization.detect_docker) {
    return callback(null, null)
    }
    if (vendorInfo) {
    return callback(null, vendorInfo)
    }
    if (!os.platform().match(/linux/i)) {
    logger.debug('Platform is not a flavor of linux, omitting docker info')
    return callback(null, null)
    }
    // try v2 path first and if null try parsing v1 path
    common.readProc(CGROUPS_V2_PATH, function getV2CGroup(err, data) {
    if (data === null) {
    logger.debug(
    `${CGROUPS_V2_PATH} not found, trying to parse container id from ${CGROUPS_V1_PATH}`
    )
    findCGroupsV1(callback)
    return
    }
    parseCGroupsV2(data, callback)
    })
    }
  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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants