在 Amazon ECS 上設定 Container Insights - Amazon CloudWatch

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

在 Amazon ECS 上設定 Container Insights

您可以使用 Amazon ECS 主控台或 在新的和現有的 Amazon ECS 叢集上設定 Container Insights 與增強的可觀測性或 Container Insights AWS CLI。Container Insights 會收集叢集、任務和服務層級的指標。Container Insights 具有增強的可觀測性,提供額外的維度和指標,可讓您深入了解容器層級的可見性。

如果您在 Amazon EC2 執行個體上使用 Amazon ECS,請使用包含 Amazon ECS 代理程式 1.29 版或更新版本的 AMI 啟動該執行個體。如需更新代理程式版本的資訊,請參閱更新 Amazon ECS 容器代理程式

注意

如果您用於 Amazon ECS Container Insights 指標的客戶受管 AWS KMS 金鑰尚未設定為使用 CloudWatch,您必須更新金鑰政策,以允許在 CloudWatch Logs 中加密日誌。您也必須將自己的 AWS KMS 金鑰與 中的日誌群組建立關聯/aws/ecs/containerinsights/ClusterName/performance。如需詳細資訊,請參閱使用 AWS Key Management Service在 CloudWatch Logs 中加密日誌資料

我們建議您使用 Container Insights 搭配增強的可觀測性,而不是 Container Insights,因為它可在您的容器環境中提供詳細可見性,從而減少解決的平均時間。

使用增強的可觀測性設定 Container Insights

您可以使用 Amazon ECS 主控台或 ,以增強可觀測性開啟 Container Insights AWS CLI。

AWS CLI

使用以下命令,以增強可觀測性開啟 Container Insights。

containerInsights帳戶設定設為 enhanced

aws ecs put-account-setting --name containerInsights --value enhanced

範例輸出

{ "setting": { "name": "containerInsights", "value": "enhanced", "principalArn": "arn:aws:iam::123456789012:johndoe", "type": user } }
注意

根據預設, put-account-setting 僅適用於目前驗證的使用者。若要為所有使用者和角色啟用全帳戶設定,請使用根使用者,如下列範例所示。

aws ecs put-account-setting --name containerInsights --value enhanced --principal-arn arn:aws:iam::accountID:root

設定此帳戶設定後,所有新叢集都會自動使用 Container Insights 與增強的可觀測性。使用 update-cluster-settings命令將具有增強型可觀測性的 Container Insights 新增至現有叢集,或將目前使用 Container Insights 的叢集升級至具有增強型可觀測性的 Container Insights。

aws ecs update-cluster-settings --cluster cluster-name --settings name=containerInsights,value=enhanced
Amazon ECS console
  1. 開啟主控台,網址為 https://console.aws.amazon.com/ecs/v2

  2. 在頂部導覽列中,選取要檢視帳戶設定的區域。

  3. 在導覽頁面中,選擇 Account Settings (帳戶設定)。

  4. 選擇更新

  5. 若要使用 Container Insights 搭配增強型可觀測性,請選擇 Container Insights 搭配增強型可觀測性

  6. 選擇儲存變更

  7. 在確認畫面,選擇確認以儲存選項。

設定此項目後,所有新叢集都會自動使用 Container Insights 與增強的可觀測性。您可以將具有增強型可觀測性的 Container Insights 新增至現有叢集,或將目前使用 Container Insights 的叢集更新為具有增強型可觀測性的 Container Insights。如需詳細資訊,請參閱《Amazon Elastic Container Service 開發人員指南》中的更新 Amazon ECS 叢集

設定容器洞見

您可以使用 Amazon ECS 主控台或 開啟 Container Insights AWS CLI。

AWS CLI

若要使用 Container Insights,請將container Insights帳戶設定設為 enabled。使用下列命令來開啟 Container Insights。

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

範例輸出

{ "setting": { "name": "container Insights", "value": "enabled", "principalArn": "arn:aws:iam::123456789012:johndoe", "type": user } }

當您將container Insights帳戶設定設定為 時enabled,所有新叢集預設都會啟用 Container Insights。使用 update-cluster-settings命令將 Container Insights 新增至現有叢集。

aws ecs update-cluster-settings --cluster cluster-name --settings name=containerInsights,value=enabled
Amazon ECS console
  1. 開啟主控台,網址為 https://console.aws.amazon.com/ecs/v2

  2. 在頂部導覽列中,選取要檢視帳戶設定的區域。

  3. 在導覽頁面中,選擇 Account Settings (帳戶設定)。

  4. 選擇更新

  5. 若要使用 Container Insights,請選擇 Container Insights

  6. 選擇儲存變更

  7. 在確認畫面,選擇確認以儲存選項。

設定此項目後,所有新叢集都會自動使用 Container Insights。更新現有叢集以新增 Container Insights。如需詳細資訊,請參閱《Amazon Elastic Container Service 開發人員指南》中的更新 Amazon ECS 叢集