本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
在 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 容器代理程式。
我們建議您使用 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
-
設定此項目後,所有新叢集都會自動使用 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
-
設定此項目後,所有新叢集都會自動使用 Container Insights。更新現有叢集以新增 Container Insights。如需詳細資訊,請參閱《Amazon Elastic Container Service 開發人員指南》中的更新 Amazon ECS 叢集。