Skip to main content

Awsecsattributes Processor

Status Maintainers: @povilasv, @iblancasa, @dmitryax Source: opentelemetry-collector-contrib

Supported Telemetry

Logs Metrics Traces

Overview

The processor discovers the ECS metadata endpoint for each container, reads the metadata, and attaches the relevant attributes to the corresponding telemetry. This complements the resourcedetection processor, which is designed for a single collector enriching its own telemetry rather than centrally enriching telemetry from many containers.

How it works

When a new container is created in ECS on EC2, the ECS Agent assigns it a metadata endpoint that is exposed to the container through the ECS_CONTAINER_METADATA_URI_V4 or ECS_CONTAINER_METADATA_URI environment variables. The processor uses the Docker API to list the running containers and read those endpoints, calls each endpoint to collect the container and task metadata, and caches the result keyed by container ID. As telemetry is received, it reads the container ID from the configured resource attribute(s) and associates the cached metadata with the corresponding telemetry.

Pre-requisites

  • Privileged mode must be enabled for the container running the collector.
  • The Docker socket must be mounted into the collector container at /var/run/docker.sock.
  • The processor uses the container ID to identify the correct metadata endpoint for each container. It looks for the container ID in the resource attribute(s) configured via container_id.sources. If no container ID can be determined, no metadata is added.
When the Docker daemon is not reachable, the processor falls back to the ECS task metadata endpoint (ECS_CONTAINER_METADATA_URI_V4) to discover the containers running in the task. The metadata cache is refreshed every 60 seconds, and also whenever the Docker API reports a new container. Failures during a refresh are logged and the last-known-good cache is preserved; the collector is not halted.

Attributes

The processor can attach the following resource attributes. By default (when attributes is omitted) all of them are collected; otherwise only the keys matching the configured attributes regex patterns are kept. Where an OpenTelemetry semantic convention exists for an attribute it is used; ECS-specific values that have no convention keep an aws.ecs.* (or legacy) key. Only containers with a valid ECS metadata endpoint are enriched; all others are ignored. A container has a valid endpoint when either ECS_CONTAINER_METADATA_URI or ECS_CONTAINER_METADATA_URI_V4 is present in its environment.

Configuration

When a container ID is sourced from a value such as log.file.name (e.g. <container-id>-json.log), the surrounding text is stripped and the 64-character container ID is used to correlate metadata. Example configuration:

Configuration

Example Configuration


Last generated: 2026-11-02