在 Amazon ECS 上設定 Container Insights - Amazon CloudWatch

在 Amazon ECS 上設定 Container Insights

可使用 Amazon ECS 主控台或 AWS CLI,在新的或現有的 Amazon ECS 叢集上設定具有增強可觀測性的 Container Insights 或 Container Insights。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 主控台或 AWS CLI 來開啟具有增強可觀測性的 Container Insights。

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 叢集

設定 Container Insights

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

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 叢集