AWS Distro for OpenTelemetry

ECS EC2 Cloudformation Template

ECS EC2 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) in Amazon Elastic Compute Cloud (Amazon EC2) mode. 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 EC2

  1. Download the CloudFormation template file for installing ADOT Collector for ECS EC2. Run the following curl command.
curl -O https://raw.githubusercontent.com/aws-observability/aws-otel-collector/main/deployment-template/ecs/aws-otel-ec2-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
    • 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 requirements): --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>
3command=<command>
4aws cloudformation create-stack --stack-name AOCECS-${ClusterName}-${Region} \
5 --template-body file://<PATH_TO_CloudFormation_TEMPLATE> \
6 --parameters ParameterKey=ClusterName,ParameterValue=${ClusterName} \
7 ParameterKey=CreateIAMRoles,ParameterValue=True \
8 ParameterKey=command,ParameterValue=${command} \
9 --capabilities CAPABILITY_NAMED_IAM \
10 --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.

On this page