Setting up Container Insights on Amazon ECS using AWS Distro for OpenTelemetry
Use this section if you want to use AWS Distro for OpenTelemetry to set up CloudWatch
Container Insights on an Amazon ECS cluster. For more information about AWS Distro for Open
Telemetry, see AWS Distro for
OpenTelemetry
These steps assume that you already have a cluster running Amazon ECS. For more information
about using AWS Distro for Open Telemetry with Amazon ECS and setting up an Amazon ECS cluster for
this purpose, see Setting up AWS
Distro for OpenTelemetry Collector in Amazon Elastic Container Service
Step 1: Create a task role
The first step is creating a task role in the cluster that the AWS OpenTelemetry Collector will use.
To create a task role for AWS Distro for OpenTelemetry
Open the IAM console at https://console.aws.amazon.com/iam/
. -
In the navigation pane, choose Policies and then choose Create policy.
-
Choose the JSON tab and copy in the following policy:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:PutLogEvents", "logs:CreateLogGroup", "logs:CreateLogStream", "logs:DescribeLogStreams", "logs:DescribeLogGroups", "ssm:GetParameters" ], "Resource": "*" } ] }
-
Choose Review policy.
-
For name, enter
AWSDistroOpenTelemetryPolicy
, and then choose Create policy. -
In the left navigation pane, choose Roles and then choose Create role.
-
In the list of services, choose Elastic Container Service.
-
Lower on the page, choose Elastic Container Service Task and then choose Next: Permissions.
-
In the list of policies, search for AWSDistroOpenTelemetryPolicy.
-
Select the check box next to AWSDistroOpenTelemetryPolicy.
-
Choose Next: Tags and then choose Next: Review.
-
For Role name enter
AWSOpenTelemetryTaskRole
and then choose Create role.
Step 2: Create a task execution role
The next step is creating a task execution role for the AWS OpenTelemetry Collector.
To create a task execution role for AWS Distro for OpenTelemetry
Open the IAM console at https://console.aws.amazon.com/iam/
. -
In the left navigation pane, choose Roles and then choose Create role.
-
In the list of services, choose Elastic Container Service.
-
Lower on the page, choose Elastic Container Service Task and then choose Next: Permissions.
-
In the list of policies, search for AmazonECSTaskExecutionRolePolicy and then select the check box next to AmazonECSTaskExecutionRolePolicy.
-
In the list of policies, search for CloudWatchLogsFullAccess and then select the check box next to CloudWatchLogsFullAccess.
-
In the list of policies, search for AmazonSSMReadOnlyAccess and then select the check box next to AmazonSSMReadOnlyAccess.
-
Choose Next: Tags and then choose Next: Review.
-
For Role name enter
AWSOpenTelemetryTaskExecutionRole
and then choose Create role.
Step 3: Create a task definition
The next step is creating a task definition.
To create a task definition for AWS Distro for OpenTelemetry
Open the console at https://console.aws.amazon.com/ecs/v2
. -
In the navigation pane, choose Task definitions
-
Choose Create new task definition, Create new task definition.
-
For Task definition family, specify a unique name for the task definition.
-
Configure your containers, and then choose Next.
-
Under Metrics and logging, select Use metric collection.
-
Choose Next.
-
Choose Create.
For more information about using the AWS OpenTelemetry collector with Amazon ECS, see
Setting up AWS Distro for
OpenTelemetry Collector in Amazon Elastic Container Service
Step 4: Run the task
The final step is running the task that you've created.
To run the task for AWS Distro for OpenTelemetry
Open the console at https://console.aws.amazon.com/ecs/v2
. -
In the left navigation pane, choose Task Definitions and then select the task that you just created.
-
Choose Actions, Deploy, Run task.
-
Choose Deploy, Run task.
-
In the Compute options section, from Existing cluster, choose the cluster.
-
Choose Create.
-
Next, you can check for the new metrics in the CloudWatch console.
Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. -
In the left navigation pane, choose Metrics.
You should see a ECS/ContainerInsights namespace. Choose that namespace and you should see eight metrics.