Docs
Install
AWS ECS

AWS ECS

This Guide Integrates:

✅ Logs✅ Metrics✖️ Traces

Installing the OpenTelemetry ECS Sidecar

The ECS sidecar container runs an OpenTelemetry collector that collects ECS task and container metrics and logs via Firelens from the application container and is preconfigured to send them to HyperDX (opens in a new tab).

To use this sidecar container in an ECS task definition, you'll need to create a new task definition with two containers: the application container and the OpenTelemetry sidecar container. The application container should be configured to use the awsfirelens log driver to forward the logs to the sidecar.

Task definition example:

{
  "family": "firelens-example-otel",
  "containerDefinitions": [
    {
      "name": "YOUR_APPLICATION_HERE",
      "image": "my_container_image",
      "essential": true,
      "logConfiguration": {
        "logDriver": "awsfirelens"
      }
    },
    {
      "name": "otel-sidecar",
      "image": "public.ecr.aws/hyperdx/aws-ecs-opentelemetry-sidecar:latest",
      "essential": true,
      "environment": [
        {
          "name": "HYPERDX_API_KEY",
          "value": "YOUR_HYPERDX_API_KEY"
        }
      ],
      "firelensConfiguration": {
        "type": "fluentbit"
      }
    }
  ],
  "networkMode": "awsvpc",
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "512",
  "memory": "1024"
}

View the examples folder in the repo (opens in a new tab) for more task definition examples and configuration options.

Configuration

You'll need to set the HYPERDX_API_KEY environment variable in the sidecar container to your HyperDX Ingestion API key. You can view API key in your team settings page (opens in a new tab).

By default, the service.name is populated by the ECS task definition family name, but this can be overridden by setting the OTEL_RESOURCE_ATTRIBUTES="service.name=my_service".

To disable the collection of ECS metrics, set the OTEL_ECS_CONTAINER_METRICS_DISABLED environment variable to true.

To disable the collection of ECS logs, ensure that the awsfirelens log driver is not set on the application container.

To debug the generated configuration, set the DEBUG_GENERATED_OTEL_CONFIG environment variable to true.

Collected ECS Metrics

The OpenTelemetry collector in the sidecar container collects the following metrics from the ECS task and container via the awsecscontainermetrics receiver (opens in a new tab) at a 1 minute interval:

Task Level MetricsContainer Level MetricsUnit
ecs.task.memory.usagecontainer.memory.usageBytes
ecs.task.memory.usage.maxcontainer.memory.usage.maxBytes
ecs.task.memory.usage.limitcontainer.memory.usage.limitBytes
ecs.task.memory.reservedcontainer.memory.reservedMegabytes
ecs.task.memory.utilizedcontainer.memory.utilizedMegabytes
ecs.task.cpu.usage.totalcontainer.cpu.usage.totalNanoseconds
ecs.task.cpu.usage.kernelmodecontainer.cpu.usage.kernelmodeNanoseconds
ecs.task.cpu.usage.usermodecontainer.cpu.usage.usermodeNanoseconds
ecs.task.cpu.usage.systemcontainer.cpu.usage.systemNanoseconds
ecs.task.cpu.usage.vcpucontainer.cpu.usage.vcpuvCPU
ecs.task.cpu.corescontainer.cpu.coresCount
ecs.task.cpu.onlinescontainer.cpu.onlinesCount
ecs.task.cpu.reservedcontainer.cpu.reservedvCPU
ecs.task.cpu.utilizedcontainer.cpu.utilizedPercent
ecs.task.network.rate.rxcontainer.network.rate.rxBytes/Second
ecs.task.network.rate.txcontainer.network.rate.txBytes/Second
ecs.task.network.io.usage.rx_bytescontainer.network.io.usage.rx_bytesBytes
ecs.task.network.io.usage.rx_packetscontainer.network.io.usage.rx_packetsCount
ecs.task.network.io.usage.rx_errorscontainer.network.io.usage.rx_errorsCount
ecs.task.network.io.usage.rx_droppedcontainer.network.io.usage.rx_droppedCount
ecs.task.network.io.usage.tx_bytescontainer.network.io.usage.tx_bytesBytes
ecs.task.network.io.usage.tx_packetscontainer.network.io.usage.tx_packetsCount
ecs.task.network.io.usage.tx_errorscontainer.network.io.usage.tx_errorsCount
ecs.task.network.io.usage.tx_droppedcontainer.network.io.usage.tx_droppedCount
ecs.task.storage.read_bytescontainer.storage.read_bytesBytes
ecs.task.storage.write_bytescontainer.storage.write_bytesBytes

Hi, how can I help you?