在 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 集群。