AWS Distro for OpenTelemetry

ECS Fargate Cloudformation Template

ECS Fargate Cloudformation Template

In this tutorial, we will demonstrate how to run OpenTelemetry Collector (ADOT Collector) as a sidecar on the Amazon Elastic Container Service (Amazon ECS) on Fargate. We provide sample applications within the same Amazon ECS task to send monitoring data to ADOT Collector.




To Install ADOT Collector by using CloudFormation, you have to have a cluster. If you are not famaliar with how to create a cluster, you can check this create-cluster section.

Setup for ECS Fargate

  1. Download CloudFormation template file for installing ADOT Collector on ECS Fargate mode on GitHub.
curl -O https://raw.githubusercontent.com/aws-observability/aws-otel-collector/main/deployment-template/ecs/aws-otel-fargate-sidecar-deployment-cfn.yaml
  1. Replace the <PATH_TO_CloudFormation_TEMPLATE> with the path where your template saved in the command, and export the following parameters, and then run CloudFormation command.
    • Cluster_Name - ECS Cluster name setup in Prerequisite step
    • AWS_Region - Region the data will be sent
    • PATH_TO_CloudFormation_TEMPLATE - CFN template path downloaded in Step 1
    • Security_Groups - the security group for your ECS Fargate Task
    • Subnets - the subnet your ECS Fargate task is running (Ex: Subnets=SubnetID1\\,SubnetID2)
    • command - Assign value to the command variable to select the config file path; the ADOT Collector comes with two configs baked in for ECS customers (choose one of them based on your purpose):
      • --config=/etc/ecs/ecs-default-config.yaml - To consume StatsD metrics, OTLP metrics/traces and X-Ray SDK traces (custom application metrics/traces)
      • --config=/etc/ecs/container-insights/otel-task-metrics-config.yaml - To Use StatsD, OTLP, Xray and Container Resource utilization metrics
1ClusterName=<Cluster_Name>
2Region=<AWS_Region>
3SecurityGroups=<Security_Groups>
4Subnets=<Subnets>
5command=<command>
6aws cloudformation create-stack --stack-name ADOTECS-${ClusterName}-${Region} \
7 --template-body file://<PATH_TO_CloudFormation_TEMPLATE> \
8 --parameters ParameterKey=ClusterName,ParameterValue=${ClusterName} \
9 ParameterKey=CreateIAMRoles,ParameterValue=True \
10 ParameterKey=SecurityGroups,ParameterValue=${SecurityGroups} \
11 ParameterKey=Subnets,ParameterValue=${Subnets} \
12 ParameterKey=command,ParameterValue=${command} \
13 --capabilities CAPABILITY_NAMED_IAM \
14 --region ${Region}
  1. Go to you ECS Console and see if the task is running.
  2. Go to the Results section to learn how to check the collected metrics and traces.