Skip to content

awsecscontainermetrics receiver: Support daemon-only /tasks/stats endpoint for instance-wide container metrics #48396

@ollypom

Description

@ollypom

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions