View a markdown version of this page

開啟 Container Insights - AWS Batch

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

開啟 Container Insights

完成下列步驟以開啟 AWS Batch 運算環境的 Container Insights。

AWS 管理主控台
  1. 開啟 AWS Batch 主控台

  2. 選擇 Environments (環境)

  3. 選擇您想要的運算環境。

  4. 容器洞見索引標籤上,開啟運算環境的容器洞見

    提示

    您可以選取預設間隔來彙總指標或建立自訂間隔。

AWS CLI

建立運算環境時啟用 Container Insights

搭配 使用 --ecs-settings 參數create-compute-environment,在新的運算環境中啟用 Container Insights。

$ aws batch create-compute-environment \ --compute-environment-name my-compute-env \ --type MANAGED \ --state ENABLED \ --ecs-settings containerInsights=ENHANCED \ --compute-resources type=FARGATE,maxvCpus=256,subnets=subnet-a123456b,securityGroupIds=sg-a12b3456

containerInsights 的有效值為 ENABLEDENHANCEDDISABLED

在現有的運算環境中啟用 Container Insights

使用 update-compute-environment 在現有的運算環境中啟用或停用 Container Insights。

$ aws batch update-compute-environment \ --compute-environment my-compute-env \ --ecs-settings containerInsights=ENHANCED

驗證 Container Insights 設定

使用 describe-compute-environments 來驗證目前的設定。

$ aws batch describe-compute-environments \ --compute-environments my-compute-env \ --query "computeEnvironments[0].ecsSettings"

以下顯示啟用 Container Insights 時的輸出。

{ "containerInsights": "ENHANCED" }
注意

如果從未在運算環境中設定 Container Insights,則回應中沒有 ecsSettings 欄位。

API

CreateComputeEnvironmentUpdateComputeEnvironment 請求中使用 ecsSettings 參數。

使用 Container Insights 建立運算環境

包含在請求內文ecsSettings中:

{ "computeEnvironmentName": "my-compute-env", "type": "MANAGED", "state": "ENABLED", "ecsSettings": { "containerInsights": "ENHANCED" }, "computeResources": { "type": "FARGATE", "maxvCpus": 256, "subnets": ["subnet-a123456b"], "securityGroupIds": ["sg-a12b3456"] } }

在現有的運算環境中更新 Container Insights

{ "computeEnvironment": "my-compute-env", "ecsSettings": { "containerInsights": "ENHANCED" } }

如需詳細資訊,請參閱 AWS Batch API 參考中的 CreateComputeEnvironmentUpdateComputeEnvironment

重要

在運算環境中設定 Container Insights 值後,您無法還原為預設 (取消設定) 行為,其中 Container Insights 設定是在 外部管理 AWS Batch。若要變更 Container Insights 模式,您必須UpdateComputeEnvironment使用新值呼叫 。

這也表示如果您在 CloudFormation 範本中設定此屬性,堆疊復原就無法將設定還原為先前的取消設定狀態。