Menu
Documentationbreadcrumb arrow Grafana Alloybreadcrumb arrow Collect and forward databreadcrumb arrow Collect ECS or Fargate OpenTelemetry data
Open source

Collect Amazon Elastic Container Service or AWS Fargate OpenTelemetry data

You can configure Grafana Alloy to collect OpenTelemetry-compatible data from Amazon Elastic Container Service (ECS) or AWS Fargate and forward it to any OpenTelemetry-compatible endpoint.

There are three different ways you can use Alloy to collect Amazon ECS or AWS Fargate telemetry data.

  1. Use a custom OpenTelemetry configuration file from the SSM Parameter store.
  2. Create an ECS task definition.
  3. Run Alloy directly in your instance, or as a Kubernetes sidecar.

Before you begin

  • Ensure that you have basic familiarity with instrumenting applications with OpenTelemetry.
  • Have an available Amazon ECS or AWS Fargate deployment.
  • Identify where Alloy writes received telemetry data.
  • Be familiar with the concept of Components in Alloy.

Use a custom OpenTelemetry configuration file from the SSM Parameter store

You can upload a custom OpenTelemetry configuration file to the SSM Parameter store and use Alloy as a telemetry data collector.

You can configure the AWS Distro for OpenTelemetry Collector with the AOT_CONFIG_CONTENT environment variable. This environment variable contains a full collector configuration file and it overrides the configuration file used in the collector entry point command. In ECS, you can set the values of environment variables from AWS Systems Manager Parameters.

Update the task definition

  1. Select the task definition.

    1. Open the AWS Systems Manager console.
    2. Select Elastic Container Service.
    3. In the navigation pane, choose Task definition.
    4. Choose Create new revision.
  2. Add an environment variable.

    1. Select the AWS Distro for OpenTelemetry Collector container and navigate to the Environment variables section.
    2. Add an environment variable named AOT_CONFIG_CONTENT.
    3. Select ValueFrom to tell ECS to get the value from the SSM Parameter, and set the value to otel-collector-config.
  3. Finish updating the task definition and create your revision.

Create the SSM parameter

  1. Open the AWS Systems Manager console.

  2. In the navigation pane, choose Parameter Store.

  3. Choose Create parameter.

  4. Create a parameter with the following values:

    • Name: otel-collector-config
    • Tier: Standard
    • Type: String
    • Data type: Text
    • Value: Copy and paste your custom OpenTelemetry configuration file or Alloy configuration file.

Run your task

When you run a task with this Task Definition, it uses your custom OpenTelemetry configuration file from the SSM Parameter store.

Refer to Running an application as an Amazon ECS task for more information about running your application as a task.

Create an ECS Task definition

To create an ECS Task Definition for AWS Fargate with an ADOT collector, complete the following steps.

  1. Download the ECS Fargate task definition template from GitHub.
  2. Edit the task definition template and add the following parameters.
    • {{region}}: The region the data is sent to.
    • {{ecsTaskRoleArn}}: The AWSOTTaskRole ARN.
    • {{ecsExecutionRoleArn}}: The AWSOTTaskExcutionRole ARN.
    • command - Assign a value to the command variable to select the path to the configuration file. The AWS Collector comes with two configurations. Select one of them based on your environment:
      • Use --config=/etc/ecs/ecs-default-config.yaml to consume StatsD metrics, OTLP metrics and traces, and X-Ray SDK traces.
      • Use --config=/etc/ecs/container-insights/otel-task-metrics-config.yaml to use StatsD, OTLP, Xray, and Container Resource utilization metrics.
  3. Follow the ECS Fargate setup instructions to create a task definition using the template.

Run Alloy directly in your instance, or as a Kubernetes sidecar

SSH or connect to the Amazon ECS or AWS Fargate-managed container. Refer to 9 steps to SSH into an AWS Fargate managed container for more information about using SSH with Amazon ECS or AWS Fargate.

You can also use your own method to connect to the Amazon ECS or AWS Fargate-managed container as long as you can pass the parameters needed to install and configure Alloy.

Install Grafana Alloy

After connecting to your instance, follow the Alloy installation, configuration and deployment instructions.