Summary
The awsecscontainermetrics receiver currently queries $ECS_CONTAINER_METADATA_URI_V4/task/stats (hardcoded as TaskStatsPath), which only returns stats for containers within the receiver's own task.
On Amazon ECS Managed Instances, tasks running as a Managed Daemon Service have access to two additional endpoints:
$ECS_CONTAINER_METADATA_URI_V4/tasks — returns metadata for all tasks on the container instance
$ECS_CONTAINER_METADATA_URI_V4/tasks/stats — returns Docker stats for all containers across all tasks on the instance
These endpoints enable a daemon to act as a per-instance metrics collector without needing the containerd socket or IMDS (both of which are inaccessible from daemon containers on Managed Instances).
Requested Change
When the receiver detects it is running as a Managed Daemon (e.g., via AWS_EXECUTION_ENV=AWS_ECS_MANAGED_INSTANCES and Group prefix daemon:), it should query /tasks/stats and /tasks instead of /task/stats and /task, returning metrics for all containers on the instance rather than just its own task.
Alternatively, a configuration option could allow users to opt-in:
receivers:
awsecscontainermetrics:
collection_interval: 60s
instance_level_metrics: true # use /tasks/stats instead of /task/stats
Context
- The
/tasks/stats response is a JSON array of per-task stats objects (same schema as /task/stats), so the existing ContainerStats struct can be reused.
- The
/tasks response is a JSON array of task metadata objects (same schema as /task).
- These endpoints are rejected for non-daemon tasks (
"Unable to get tasks stats"), so detection or explicit configuration is needed.
References
Summary
The
awsecscontainermetricsreceiver currently queries$ECS_CONTAINER_METADATA_URI_V4/task/stats(hardcoded asTaskStatsPath), which only returns stats for containers within the receiver's own task.On Amazon ECS Managed Instances, tasks running as a Managed Daemon Service have access to two additional endpoints:
$ECS_CONTAINER_METADATA_URI_V4/tasks— returns metadata for all tasks on the container instance$ECS_CONTAINER_METADATA_URI_V4/tasks/stats— returns Docker stats for all containers across all tasks on the instanceThese endpoints enable a daemon to act as a per-instance metrics collector without needing the containerd socket or IMDS (both of which are inaccessible from daemon containers on Managed Instances).
Requested Change
When the receiver detects it is running as a Managed Daemon (e.g., via
AWS_EXECUTION_ENV=AWS_ECS_MANAGED_INSTANCESandGroupprefixdaemon:), it should query/tasks/statsand/tasksinstead of/task/statsand/task, returning metrics for all containers on the instance rather than just its own task.Alternatively, a configuration option could allow users to opt-in:
Context
/tasks/statsresponse is a JSON array of per-task stats objects (same schema as/task/stats), so the existingContainerStatsstruct can be reused./tasksresponse is a JSON array of task metadata objects (same schema as/task)."Unable to get tasks stats"), so detection or explicit configuration is needed.References
TaskStatsPathconstant in sourceStatsProvider.GetStats()in source