在 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 容器代理程式。
我們建議您使用具有增強可觀測性的 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
-
設定它之後,所有新叢集會自動使用具有增強可觀測性的 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
-
設定它之後,所有新叢集會自動使用 Container Insights。更新現有叢集以新增 Container Insights。如需詳細資訊,請參閱 Amazon Elastic Container Service 開發人員指南中的更新 Amazon ECS 叢集。