Setting up Container Insights on Amazon ECS for cluster- and service-level metrics - Amazon CloudWatch

Setting up Container Insights on Amazon ECS for cluster- and service-level metrics

You can enable Container Insights on new and existing Amazon ECS clusters. Container Insights collects metrics at the cluster, task, and service levels. You can enable Container Insights using either the Amazon ECS console or the AWS CLI.

If you're using Amazon ECS on an Amazon EC2 instance, and you want to collect network and storage metrics from Container Insights, launch that instance using an AMI that includes Amazon ECS agent version 1.29. For information about updating your agent version, see Updating the Amazon ECS Container Agent

You can use the AWS CLI to set account-level permission to enable Container Insights for any new Amazon ECS clusters created in your account. To do so, enter the following command.

aws ecs put-account-setting --name "containerInsights" --value "enabled"
Note

If the customer managed AWS KMS key you use for your Amazon ECS Container Insights metrics is not already configured to work with CloudWatch, you must update the key policy to allow for encrypted logs in CloudWatch Logs. You must also associate your own AWS KMS key with the log group under /aws/ecs/containerinsights/ClusterName/performance. For more information, see Encrypt log data in CloudWatch Logs using AWS Key Management Service.

Setting up Container Insights on existing Amazon ECS clusters

To enable Container Insights on an existing Amazon ECS cluster, enter the following command. You must be running version 1.16.200 or later of the AWS CLI for the following command to work.

aws ecs update-cluster-settings --cluster myCICluster --settings name=containerInsights,value=enabled

Setting up Container Insights on new Amazon ECS clusters

There are two ways to enable Container Insights on new Amazon ECS clusters. You can configure Amazon ECS so that all new clusters are enabled for Container Insights by default. Otherwise, you can enable a new cluster when you create it.

Using the AWS Management Console

You can turn on Container Insights on all new clusters by default, or on an individual cluster as you create it.

To turn on Container Insights on all new clusters by default
  1. Open the console at https://console.aws.amazon.com/ecs/v2.

  2. In the navigation page, choose Account Settings.

  3. Choose Update.

  4. To use CloudWatch Container Insights by default for clusters, under CloudWatch Container Insights, select or clear CloudWatch Container Insights.

  5. Choose Save changes.

If you haven't used the preceding procedure to enable Container Insights on all new clusters by default, use the following steps to create a cluster with Container Insights enabled.

To create a cluster with Container Insights turned on
  1. Open the console at https://console.aws.amazon.com/ecs/v2.

  2. In the navigation pane, choose Clusters.

  3. On the Clusters page, choose Create cluster.

  4. Under Cluster configuration, for Cluster name, enter a unique name.

    The name can contain up to 255 letters (uppercase and lowercase), numbers, and hyphens.

  5. To turn on Container Insights, expand Monitoring, and then turn on Use Container Insights.

You can now create task definitions, run tasks, and launch services in the cluster. For more information, see the following:

Setting up Container Insights on new Amazon ECS clusters using the AWS CLI

To enable Container Insights on all new clusters by default, enter the following command.

aws ecs put-account-setting --name "containerInsights" --value "enabled"

If you didn't use the preceding command to enable Container Insights on all new clusters by default, enter the following command to create a new cluster with Container Insights enabled. You must be running version 1.16.200 or later of the AWS CLI for the following command to work.

aws ecs create-cluster --cluster-name myCICluster --settings "name=containerInsights,value=enabled"

Disabling Container Insights on Amazon ECS clusters

To disable Container Insights on an existing Amazon ECS cluster, enter the following command.

aws ecs update-cluster-settings --cluster myCICluster --settings name=containerInsights,value=disabled