任务元数据终端节点版本 4 - Amazon Elastic Container Service
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

任务元数据终端节点版本 4

重要

如果您使用在 上托管Amazon ECS的任务AWS Fargate,请参阅 中的https://docs.amazonaws.cn/AmazonECS/latest/userguide/task-metadata-endpoint-v4-fargate.html任务元数据终端节点版本 适用于 AWS Fargate 的 Amazon Elastic Container Service 用户指南4。

Amazon ECS 容器代理将环境变量注入到每个容器中,称为任务元数据终端节点,该终端节点向容器提供各种任务元数据和 Docker 统计数据

任务元数据和网络速率统计数据将发送到 CloudWatch Container Insights ,并且可以在 中查看AWS 管理控制台。有关更多信息,请参阅Amazon ECS CloudWatch Container Insights.

注意

Amazon ECS 提供任务元数据终端节点的早期版本。为避免将来需要创建新的任务元数据终端节点版本,可能会将其他元数据添加到版本 4 输出中。我们不会删除任何现有元数据或更改元数据字段名称。

启用任务元数据终端节点

默认情况下, 环境变量将注入在至少运行 容器代理版本的 Amazon ECS 实例上启动Amazon EC2的任务1.39.0的Amazon ECS容器中。有关更多信息,请参阅Amazon ECS 容器代理版本.

注意

您可以通过将代理更新为最新版本,在使用旧版 Amazon EC2 容器代理Amazon ECS的实例上添加对此功能的支持。有关更多信息,请参阅更新 Amazon ECS 容器代理.

任务元数据终端节点版本 4 路径

以下任务元数据终端节点路径可用于容器。

${ECS_CONTAINER_METADATA_URI_V4}

此路径返回容器的元数据。

${ECS_CONTAINER_METADATA_URI_V4}/task

此路径返回任务的元数据,包括容器列表IDs以及与任务关联的所有容器的名称。有关此终端节点响应的更多信息,请参阅任务元数据 JSON 响应.

${ECS_CONTAINER_METADATA_URI_V4}/taskWithTags

此路径将返回/task终端节点中包含的任务的元数据以及可以使用 ListTagsForResource API 检索的任务和容器实例标签。在检索标签元数据时收到的任何错误都将包含在响应的 Errors 字段中。

注意

对于在运行最低版本的 容器代理Errors的 实例上托管的任务Amazon EC2, 1.50.0 字段仅在响应中。

${ECS_CONTAINER_METADATA_URI_V4}/stats

此路径返回特定容器的 Docker 统计数据。有关返回的每个统计数据的更多信息,请参阅 Docker API ContainerStats 文档中的 。

对于使用 Amazon ECS 或托管在至少运行 awsvpc 容器代理版本的 bridge 实例上的Amazon EC2网络模式1.43.0的任务,响应中将包含其他网络速率统计数据。对于所有其他任务,响应将仅包含累积网络统计数据。

${ECS_CONTAINER_METADATA_URI_V4}/task/stats

此路径返回与任务关联的所有容器的 Docker 统计数据。附加容器可以使用此路径提取网络指标。有关返回的每个统计数据的更多信息,请参阅 Docker API ContainerStats 文档中的 。

对于使用 Amazon ECS 或托管在至少运行awsvpc容器代理版本的 bridge 实例上的Amazon EC2网络模式1.43.0的任务,响应中将包含其他网络速率统计数据。对于所有其他任务,响应将仅包含累积网络统计数据。

任务元数据 JSON 响应

以下信息返回自任务元数据终端节点 (${ECS_CONTAINER_METADATA_URI_V4}/task) JSON 响应。这包括与任务关联的元数据以及任务中每个容器的元数据。

Cluster

此任务所属的 Amazon ECS 集群的 Amazon 资源名称 (ARN) 或短名称。

TaskARN

容器所属的任务的完整 Amazon 资源名称 (ARN)。

Family

任务的 Amazon ECS 任务定义系列。

Revision

任务的 Amazon ECS 任务定义修订。

DesiredStatus

来自 Amazon ECS 的任务的所需状态。

KnownStatus

来自 Amazon ECS 的任务的已知状态。

Limits

在任务级别上指定的资源限制 (如 CPU 和内存)。如果未定义资源限制,则省略此参数。

PullStartedAt

开始提取第一个容器映像时的时间戳。

PullStoppedAt

完成提取最后一个容器映像时的时间戳。

AvailabilityZone

任务所在的可用区。

注意

可用区元数据仅适用于使用平台版本 1.4 或更高版本的 Fargate任务。

LaunchType

任务使用的启动类型。使用集群容量提供程序时,这表示任务是使用 Fargate 还是 EC2 基础设施。

注意

仅当使用 Amazon ECS 容器代理版本 1.45.0 或更高版本时,才包含此 LaunchType 元数据。

Containers

与任务关联的每个容器的容器元数据列表。

DockerId

容器的 Docker ID。

Name

任务定义中所指定的容器的名称。

DockerName

提供给 Docker 的容器的名称。Amazon ECS 容器代理为容器生成一个唯一名称,以避免相同任务定义的多个副本在一个实例上运行时发生名称冲突。

Image

容器的映像。

ImageID

容器的 SHA-256 摘要。

Ports

对于容器公开的任何端口。如果没有公开的端口,则省略此参数。

Labels

应用到容器的任何标签。如果没有应用的标签,则省略此参数。

DesiredStatus

来自 Amazon ECS 的容器的所需状态。

KnownStatus

来自 Amazon ECS 的容器的已知状态。

ExitCode

容器的退出代码。如果没有容器退出,则省略此参数。

Limits

在容器级别上指定的资源限制 (如 CPU 和内存)。如果未定义资源限制,则省略此参数。

CreatedAt

创建容器时的时间戳。如果尚未创建容器,则省略此参数。

StartedAt

容器启动时的时间戳。如果尚未启动容器,则省略此参数。

FinishedAt

容器停止时的时间戳。如果尚未停止容器,则省略此参数。

Type

容器的类型。在您的任务定义中指定的容器属于 NORMAL 类型。您可以省略其他被 容器代理用来进行内部任务资源预配置的容器类型。

LogDriver

容器正在使用的日志驱动程序。

注意

仅当使用 Amazon ECS 容器代理版本 1.45.0 或更高版本时,才包含此 LogDriver 元数据。

LogOptions

为容器定义的日志驱动程序选项。

注意

仅当使用 Amazon ECS 容器代理版本 1.45.0 或更高版本时,才包含此 LogOptions 元数据。

ContainerARN

容器的完整 Amazon 资源名称 (ARN)。

注意

仅当使用 Amazon ECS 容器代理版本 1.45.0 或更高版本时,才包含此 ContainerARN 元数据。

Networks

容器的网络信息,如网络模式和 IP 地址。如果未定义网络信息,则省略此参数。

ExecutionStoppedAt

任务的 DesiredStatus 变为 STOPPED 时的时间戳。这将发生在关键容器变成 STOPPED 时。

Examples

以下示例显示了每个任务元数据终端节点的示例输出。

示例容器元数据响应

查询 ${ECS_CONTAINER_METADATA_URI_V4} 终端节点时,仅返回有关容器本身的元数据。下面是一个示例输出。

{ "DockerId": "ea32192c8553fbff06c9340478a2ff089b2bb5646fb718b4ee206641c9086d66", "Name": "curl", "DockerName": "ecs-curltest-24-curl-cca48e8dcadd97805600", "Image": "111122223333.dkr.ecr.us-west-2.amazonaws.com/curltest:latest", "ImageID": "sha256:d691691e9652791a60114e67b365688d20d19940dde7c4736ea30e660d8d3553", "Labels": { "com.amazonaws.ecs.cluster": "default", "com.amazonaws.ecs.container-name": "curl", "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:111122223333:task/default/8f03e41243824aea923aca126495f665", "com.amazonaws.ecs.task-definition-family": "curltest", "com.amazonaws.ecs.task-definition-version": "24" }, "DesiredStatus": "RUNNING", "KnownStatus": "RUNNING", "Limits": { "CPU": 10, "Memory": 128 }, "CreatedAt": "2020-10-02T00:15:07.620912337Z", "StartedAt": "2020-10-02T00:15:08.062559351Z", "Type": "NORMAL", "LogDriver": "awslogs", "LogOptions": { "awslogs-create-group": "true", "awslogs-group": "/ecs/metadata", "awslogs-region": "us-west-2", "awslogs-stream": "ecs/curl/8f03e41243824aea923aca126495f665" }, "ContainerARN": "arn:aws:ecs:us-west-2:111122223333:container/0206b271-b33f-47ab-86c6-a0ba208a70a9", "Networks": [ { "NetworkMode": "awsvpc", "IPv4Addresses": [ "10.0.2.100" ], "AttachmentIndex": 0, "MACAddress": "0e:9e:32:c7:48:85", "IPv4SubnetCIDRBlock": "10.0.2.0/24", "PrivateDNSName": "ip-10-0-2-100.us-west-2.compute.internal", "SubnetGatewayIpv4Address": "10.0.2.1/24" } ] }

任务元数据响应示例

查询${ECS_CONTAINER_METADATA_URI_V4}/task终端节点时,除了返回任务中每个容器的元数据以外,还将返回有关容器所属的任务的元数据。下面是一个示例输出。

{ "Cluster": "default", "TaskARN": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "Family": "curltest", "Revision": "26", "DesiredStatus": "RUNNING", "KnownStatus": "RUNNING", "PullStartedAt": "2020-10-02T00:43:06.202617438Z", "PullStoppedAt": "2020-10-02T00:43:06.31288465Z", "AvailabilityZone": "us-west-2d", "LaunchType": "EC2", "Containers": [ { "DockerId": "598cba581fe3f939459eaba1e071d5c93bb2c49b7d1ba7db6bb19deeb70d8e38", "Name": "~internal~ecs~pause", "DockerName": "ecs-curltest-26-internalecspause-e292d586b6f9dade4a00", "Image": "amazon/amazon-ecs-pause:0.1.0", "ImageID": "", "Labels": { "com.amazonaws.ecs.cluster": "default", "com.amazonaws.ecs.container-name": "~internal~ecs~pause", "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "com.amazonaws.ecs.task-definition-family": "curltest", "com.amazonaws.ecs.task-definition-version": "26" }, "DesiredStatus": "RESOURCES_PROVISIONED", "KnownStatus": "RESOURCES_PROVISIONED", "Limits": { "CPU": 0, "Memory": 0 }, "CreatedAt": "2020-10-02T00:43:05.602352471Z", "StartedAt": "2020-10-02T00:43:06.076707576Z", "Type": "CNI_PAUSE", "Networks": [ { "NetworkMode": "awsvpc", "IPv4Addresses": [ "10.0.2.61" ], "AttachmentIndex": 0, "MACAddress": "0e:10:e2:01:bd:91", "IPv4SubnetCIDRBlock": "10.0.2.0/24", "PrivateDNSName": "ip-10-0-2-61.us-west-2.compute.internal", "SubnetGatewayIpv4Address": "10.0.2.1/24" } ] }, { "DockerId": "ee08638adaaf009d78c248913f629e38299471d45fe7dc944d1039077e3424ca", "Name": "curl", "DockerName": "ecs-curltest-26-curl-a0e7dba5aca6d8cb2e00", "Image": "111122223333.dkr.ecr.us-west-2.amazonaws.com/curltest:latest", "ImageID": "sha256:d691691e9652791a60114e67b365688d20d19940dde7c4736ea30e660d8d3553", "Labels": { "com.amazonaws.ecs.cluster": "default", "com.amazonaws.ecs.container-name": "curl", "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "com.amazonaws.ecs.task-definition-family": "curltest", "com.amazonaws.ecs.task-definition-version": "26" }, "DesiredStatus": "RUNNING", "KnownStatus": "RUNNING", "Limits": { "CPU": 10, "Memory": 128 }, "CreatedAt": "2020-10-02T00:43:06.326590752Z", "StartedAt": "2020-10-02T00:43:06.767535449Z", "Type": "NORMAL", "LogDriver": "awslogs", "LogOptions": { "awslogs-create-group": "true", "awslogs-group": "/ecs/metadata", "awslogs-region": "us-west-2", "awslogs-stream": "ecs/curl/158d1c8083dd49d6b527399fd6414f5c" }, "ContainerARN": "arn:aws:ecs:us-west-2:111122223333:container/abb51bdd-11b4-467f-8f6c-adcfe1fe059d", "Networks": [ { "NetworkMode": "awsvpc", "IPv4Addresses": [ "10.0.2.61" ], "AttachmentIndex": 0, "MACAddress": "0e:10:e2:01:bd:91", "IPv4SubnetCIDRBlock": "10.0.2.0/24", "PrivateDNSName": "ip-10-0-2-61.us-west-2.compute.internal", "SubnetGatewayIpv4Address": "10.0.2.1/24" } ] } ] }

具有标签元数据响应的示例任务

查询${ECS_CONTAINER_METADATA_URI_V4}/taskWithTags终端节点时,将返回有关任务的元数据,包括任务和容器实例标签。下面是一个示例输出。

{ "Cluster": "default", "TaskARN": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "Family": "curltest", "Revision": "26", "DesiredStatus": "RUNNING", "KnownStatus": "RUNNING", "PullStartedAt": "2020-10-02T00:43:06.202617438Z", "PullStoppedAt": "2020-10-02T00:43:06.31288465Z", "AvailabilityZone": "us-west-2d", "TaskTags": { "tag-use": "task-metadata-endpoint-test" }, "ContainerInstanceTags":{ "tag_key":"tag_value" }, "LaunchType": "EC2", "Containers": [ { "DockerId": "598cba581fe3f939459eaba1e071d5c93bb2c49b7d1ba7db6bb19deeb70d8e38", "Name": "~internal~ecs~pause", "DockerName": "ecs-curltest-26-internalecspause-e292d586b6f9dade4a00", "Image": "amazon/amazon-ecs-pause:0.1.0", "ImageID": "", "Labels": { "com.amazonaws.ecs.cluster": "default", "com.amazonaws.ecs.container-name": "~internal~ecs~pause", "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "com.amazonaws.ecs.task-definition-family": "curltest", "com.amazonaws.ecs.task-definition-version": "26" }, "DesiredStatus": "RESOURCES_PROVISIONED", "KnownStatus": "RESOURCES_PROVISIONED", "Limits": { "CPU": 0, "Memory": 0 }, "CreatedAt": "2020-10-02T00:43:05.602352471Z", "StartedAt": "2020-10-02T00:43:06.076707576Z", "Type": "CNI_PAUSE", "Networks": [ { "NetworkMode": "awsvpc", "IPv4Addresses": [ "10.0.2.61" ], "AttachmentIndex": 0, "MACAddress": "0e:10:e2:01:bd:91", "IPv4SubnetCIDRBlock": "10.0.2.0/24", "PrivateDNSName": "ip-10-0-2-61.us-west-2.compute.internal", "SubnetGatewayIpv4Address": "10.0.2.1/24" } ] }, { "DockerId": "ee08638adaaf009d78c248913f629e38299471d45fe7dc944d1039077e3424ca", "Name": "curl", "DockerName": "ecs-curltest-26-curl-a0e7dba5aca6d8cb2e00", "Image": "111122223333.dkr.ecr.us-west-2.amazonaws.com/curltest:latest", "ImageID": "sha256:d691691e9652791a60114e67b365688d20d19940dde7c4736ea30e660d8d3553", "Labels": { "com.amazonaws.ecs.cluster": "default", "com.amazonaws.ecs.container-name": "curl", "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "com.amazonaws.ecs.task-definition-family": "curltest", "com.amazonaws.ecs.task-definition-version": "26" }, "DesiredStatus": "RUNNING", "KnownStatus": "RUNNING", "Limits": { "CPU": 10, "Memory": 128 }, "CreatedAt": "2020-10-02T00:43:06.326590752Z", "StartedAt": "2020-10-02T00:43:06.767535449Z", "Type": "NORMAL", "LogDriver": "awslogs", "LogOptions": { "awslogs-create-group": "true", "awslogs-group": "/ecs/metadata", "awslogs-region": "us-west-2", "awslogs-stream": "ecs/curl/158d1c8083dd49d6b527399fd6414f5c" }, "ContainerARN": "arn:aws:ecs:us-west-2:111122223333:container/abb51bdd-11b4-467f-8f6c-adcfe1fe059d", "Networks": [ { "NetworkMode": "awsvpc", "IPv4Addresses": [ "10.0.2.61" ], "AttachmentIndex": 0, "MACAddress": "0e:10:e2:01:bd:91", "IPv4SubnetCIDRBlock": "10.0.2.0/24", "PrivateDNSName": "ip-10-0-2-61.us-west-2.compute.internal", "SubnetGatewayIpv4Address": "10.0.2.1/24" } ] } ] }

具有带错误元数据响应的标签的示例任务

在查询${ECS_CONTAINER_METADATA_URI_V4}/taskWithTags终端节点时,将返回有关任务的元数据,包括任务和容器实例标签。如果检索标记数据时出错,将在响应中返回错误。以下是与容器实例关联的IAM角色没有允许ecs:ListTagsForResource的权限时的示例输出。

{ "Cluster": "default", "TaskARN": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "Family": "curltest", "Revision": "26", "DesiredStatus": "RUNNING", "KnownStatus": "RUNNING", "PullStartedAt": "2020-10-02T00:43:06.202617438Z", "PullStoppedAt": "2020-10-02T00:43:06.31288465Z", "AvailabilityZone": "us-west-2d", "Errors": [ { "ErrorField": "ContainerInstanceTags", "ErrorCode": "AccessDeniedException", "ErrorMessage": "User: arn:aws:sts::111122223333:assumed-role/ecsInstanceRole/i-0744a608689EXAMPLE is not authorized to perform: ecs:ListTagsForResource on resource: arn:aws:ecs:us-west-2:111122223333:container-instance/default/2dd1b186f39845a584488d2ef155c131", "StatusCode": 400, "RequestId": "cd597ef0-272b-4643-9bd2-1de469870fa6", "ResourceARN": "arn:aws:ecs:us-west-2:111122223333:container-instance/default/2dd1b186f39845a584488d2ef155c131" }, { "ErrorField": "TaskTags", "ErrorCode": "AccessDeniedException", "ErrorMessage": "User: arn:aws:sts::111122223333:assumed-role/ecsInstanceRole/i-0744a608689EXAMPLE is not authorized to perform: ecs:ListTagsForResource on resource: arn:aws:ecs:us-west-2:111122223333:task/default/9ef30e4b7aa44d0db562749cff4983f3", "StatusCode": 400, "RequestId": "862c5986-6cd2-4aa6-87cc-70be395531e1", "ResourceARN": "arn:aws:ecs:us-west-2:111122223333:task/default/9ef30e4b7aa44d0db562749cff4983f3" } ], "LaunchType": "EC2", "Containers": [ { "DockerId": "598cba581fe3f939459eaba1e071d5c93bb2c49b7d1ba7db6bb19deeb70d8e38", "Name": "~internal~ecs~pause", "DockerName": "ecs-curltest-26-internalecspause-e292d586b6f9dade4a00", "Image": "amazon/amazon-ecs-pause:0.1.0", "ImageID": "", "Labels": { "com.amazonaws.ecs.cluster": "default", "com.amazonaws.ecs.container-name": "~internal~ecs~pause", "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "com.amazonaws.ecs.task-definition-family": "curltest", "com.amazonaws.ecs.task-definition-version": "26" }, "DesiredStatus": "RESOURCES_PROVISIONED", "KnownStatus": "RESOURCES_PROVISIONED", "Limits": { "CPU": 0, "Memory": 0 }, "CreatedAt": "2020-10-02T00:43:05.602352471Z", "StartedAt": "2020-10-02T00:43:06.076707576Z", "Type": "CNI_PAUSE", "Networks": [ { "NetworkMode": "awsvpc", "IPv4Addresses": [ "10.0.2.61" ], "AttachmentIndex": 0, "MACAddress": "0e:10:e2:01:bd:91", "IPv4SubnetCIDRBlock": "10.0.2.0/24", "PrivateDNSName": "ip-10-0-2-61.us-west-2.compute.internal", "SubnetGatewayIpv4Address": "10.0.2.1/24" } ] }, { "DockerId": "ee08638adaaf009d78c248913f629e38299471d45fe7dc944d1039077e3424ca", "Name": "curl", "DockerName": "ecs-curltest-26-curl-a0e7dba5aca6d8cb2e00", "Image": "111122223333.dkr.ecr.us-west-2.amazonaws.com/curltest:latest", "ImageID": "sha256:d691691e9652791a60114e67b365688d20d19940dde7c4736ea30e660d8d3553", "Labels": { "com.amazonaws.ecs.cluster": "default", "com.amazonaws.ecs.container-name": "curl", "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c", "com.amazonaws.ecs.task-definition-family": "curltest", "com.amazonaws.ecs.task-definition-version": "26" }, "DesiredStatus": "RUNNING", "KnownStatus": "RUNNING", "Limits": { "CPU": 10, "Memory": 128 }, "CreatedAt": "2020-10-02T00:43:06.326590752Z", "StartedAt": "2020-10-02T00:43:06.767535449Z", "Type": "NORMAL", "LogDriver": "awslogs", "LogOptions": { "awslogs-create-group": "true", "awslogs-group": "/ecs/metadata", "awslogs-region": "us-west-2", "awslogs-stream": "ecs/curl/158d1c8083dd49d6b527399fd6414f5c" }, "ContainerARN": "arn:aws:ecs:us-west-2:111122223333:container/abb51bdd-11b4-467f-8f6c-adcfe1fe059d", "Networks": [ { "NetworkMode": "awsvpc", "IPv4Addresses": [ "10.0.2.61" ], "AttachmentIndex": 0, "MACAddress": "0e:10:e2:01:bd:91", "IPv4SubnetCIDRBlock": "10.0.2.0/24", "PrivateDNSName": "ip-10-0-2-61.us-west-2.compute.internal", "SubnetGatewayIpv4Address": "10.0.2.1/24" } ] } ] }

示例容器统计数据响应

查询${ECS_CONTAINER_METADATA_URI_V4}/stats终端节点时,将返回容器的网络指标。对于使用 Amazon ECS 或托管在至少运行awsvpc容器代理版本的 bridge 实例上的Amazon EC2网络模式1.43.0的任务,响应中将包含其他网络速率统计数据。对于所有其他任务,响应将仅包含累积网络统计数据。

以下是使用 Amazon ECS 网络模式Amazon EC2的 上的 bridge 任务的示例输出。

{ "read": "2020-10-02T00:51:13.410254284Z", "preread": "2020-10-02T00:51:12.406202398Z", "pids_stats": { "current": 3 }, "blkio_stats": { "io_service_bytes_recursive": [ ], "io_serviced_recursive": [ ], "io_queue_recursive": [ ], "io_service_time_recursive": [ ], "io_wait_time_recursive": [ ], "io_merged_recursive": [ ], "io_time_recursive": [ ], "sectors_recursive": [ ] }, "num_procs": 0, "storage_stats": { }, "cpu_stats": { "cpu_usage": { "total_usage": 360968065, "percpu_usage": [ 182359190, 178608875 ], "usage_in_kernelmode": 40000000, "usage_in_usermode": 290000000 }, "system_cpu_usage": 13939680000000, "online_cpus": 2, "throttling_data": { "periods": 0, "throttled_periods": 0, "throttled_time": 0 } }, "precpu_stats": { "cpu_usage": { "total_usage": 360968065, "percpu_usage": [ 182359190, 178608875 ], "usage_in_kernelmode": 40000000, "usage_in_usermode": 290000000 }, "system_cpu_usage": 13937670000000, "online_cpus": 2, "throttling_data": { "periods": 0, "throttled_periods": 0, "throttled_time": 0 } }, "memory_stats": { "usage": 1806336, "max_usage": 6299648, "stats": { "active_anon": 606208, "active_file": 0, "cache": 0, "dirty": 0, "hierarchical_memory_limit": 134217728, "hierarchical_memsw_limit": 268435456, "inactive_anon": 0, "inactive_file": 0, "mapped_file": 0, "pgfault": 4185, "pgmajfault": 0, "pgpgin": 2926, "pgpgout": 2778, "rss": 606208, "rss_huge": 0, "total_active_anon": 606208, "total_active_file": 0, "total_cache": 0, "total_dirty": 0, "total_inactive_anon": 0, "total_inactive_file": 0, "total_mapped_file": 0, "total_pgfault": 4185, "total_pgmajfault": 0, "total_pgpgin": 2926, "total_pgpgout": 2778, "total_rss": 606208, "total_rss_huge": 0, "total_unevictable": 0, "total_writeback": 0, "unevictable": 0, "writeback": 0 }, "limit": 134217728 }, "name": "/ecs-curltest-26-curl-c2e5f6e0cf91b0bead01", "id": "5fc21e5b015f899d22618f8aede80b6d70d71b2a75465ea49d9462c8f3d2d3af", "networks": { "eth0": { "rx_bytes": 84, "rx_packets": 2, "rx_errors": 0, "rx_dropped": 0, "tx_bytes": 84, "tx_packets": 2, "tx_errors": 0, "tx_dropped": 0 } }, "network_rate_stats": { "rx_bytes_per_sec": 0, "tx_bytes_per_sec": 0 } }

示例任务统计数据响应

查询 ${ECS_CONTAINER_METADATA_URI_V4}/task/stats 终端节点时,将返回有关容器所属的任务的网络指标。下面是一个示例输出。

{ "01999f2e5c6cf4df3873f28950e6278813408f281c54778efec860d0caad4854": { "read": "2020-10-02T00:51:32.51467703Z", "preread": "2020-10-02T00:51:31.50860463Z", "pids_stats": { "current": 1 }, "blkio_stats": { "io_service_bytes_recursive": [ ], "io_serviced_recursive": [ ], "io_queue_recursive": [ ], "io_service_time_recursive": [ ], "io_wait_time_recursive": [ ], "io_merged_recursive": [ ], "io_time_recursive": [ ], "sectors_recursive": [ ] }, "num_procs": 0, "storage_stats": { }, "cpu_stats": { "cpu_usage": { "total_usage": 177232665, "percpu_usage": [ 13376224, 163856441 ], "usage_in_kernelmode": 0, "usage_in_usermode": 160000000 }, "system_cpu_usage": 13977820000000, "online_cpus": 2, "throttling_data": { "periods": 0, "throttled_periods": 0, "throttled_time": 0 } }, "precpu_stats": { "cpu_usage": { "total_usage": 177232665, "percpu_usage": [ 13376224, 163856441 ], "usage_in_kernelmode": 0, "usage_in_usermode": 160000000 }, "system_cpu_usage": 13975800000000, "online_cpus": 2, "throttling_data": { "periods": 0, "throttled_periods": 0, "throttled_time": 0 } }, "memory_stats": { "usage": 532480, "max_usage": 6279168, "stats": { "active_anon": 40960, "active_file": 0, "cache": 0, "dirty": 0, "hierarchical_memory_limit": 9223372036854771712, "hierarchical_memsw_limit": 9223372036854771712, "inactive_anon": 0, "inactive_file": 0, "mapped_file": 0, "pgfault": 2033, "pgmajfault": 0, "pgpgin": 1734, "pgpgout": 1724, "rss": 40960, "rss_huge": 0, "total_active_anon": 40960, "total_active_file": 0, "total_cache": 0, "total_dirty": 0, "total_inactive_anon": 0, "total_inactive_file": 0, "total_mapped_file": 0, "total_pgfault": 2033, "total_pgmajfault": 0, "total_pgpgin": 1734, "total_pgpgout": 1724, "total_rss": 40960, "total_rss_huge": 0, "total_unevictable": 0, "total_writeback": 0, "unevictable": 0, "writeback": 0 }, "limit": 4073377792 }, "name": "/ecs-curltest-26-internalecspause-a6bcc3dbadfacfe85300", "id": "01999f2e5c6cf4df3873f28950e6278813408f281c54778efec860d0caad4854", "networks": { "eth0": { "rx_bytes": 84, "rx_packets": 2, "rx_errors": 0, "rx_dropped": 0, "tx_bytes": 84, "tx_packets": 2, "tx_errors": 0, "tx_dropped": 0 } }, "network_rate_stats": { "rx_bytes_per_sec": 0, "tx_bytes_per_sec": 0 } }, "5fc21e5b015f899d22618f8aede80b6d70d71b2a75465ea49d9462c8f3d2d3af": { "read": "2020-10-02T00:51:32.512771349Z", "preread": "2020-10-02T00:51:31.510597736Z", "pids_stats": { "current": 3 }, "blkio_stats": { "io_service_bytes_recursive": [ ], "io_serviced_recursive": [ ], "io_queue_recursive": [ ], "io_service_time_recursive": [ ], "io_wait_time_recursive": [ ], "io_merged_recursive": [ ], "io_time_recursive": [ ], "sectors_recursive": [ ] }, "num_procs": 0, "storage_stats": { }, "cpu_stats": { "cpu_usage": { "total_usage": 379075681, "percpu_usage": [ 191355275, 187720406 ], "usage_in_kernelmode": 60000000, "usage_in_usermode": 310000000 }, "system_cpu_usage": 13977800000000, "online_cpus": 2, "throttling_data": { "periods": 0, "throttled_periods": 0, "throttled_time": 0 } }, "precpu_stats": { "cpu_usage": { "total_usage": 378825197, "percpu_usage": [ 191104791, 187720406 ], "usage_in_kernelmode": 60000000, "usage_in_usermode": 310000000 }, "system_cpu_usage": 13975800000000, "online_cpus": 2, "throttling_data": { "periods": 0, "throttled_periods": 0, "throttled_time": 0 } }, "memory_stats": { "usage": 1814528, "max_usage": 6299648, "stats": { "active_anon": 606208, "active_file": 0, "cache": 0, "dirty": 0, "hierarchical_memory_limit": 134217728, "hierarchical_memsw_limit": 268435456, "inactive_anon": 0, "inactive_file": 0, "mapped_file": 0, "pgfault": 5377, "pgmajfault": 0, "pgpgin": 3613, "pgpgout": 3465, "rss": 606208, "rss_huge": 0, "total_active_anon": 606208, "total_active_file": 0, "total_cache": 0, "total_dirty": 0, "total_inactive_anon": 0, "total_inactive_file": 0, "total_mapped_file": 0, "total_pgfault": 5377, "total_pgmajfault": 0, "total_pgpgin": 3613, "total_pgpgout": 3465, "total_rss": 606208, "total_rss_huge": 0, "total_unevictable": 0, "total_writeback": 0, "unevictable": 0, "writeback": 0 }, "limit": 134217728 }, "name": "/ecs-curltest-26-curl-c2e5f6e0cf91b0bead01", "id": "5fc21e5b015f899d22618f8aede80b6d70d71b2a75465ea49d9462c8f3d2d3af", "networks": { "eth0": { "rx_bytes": 84, "rx_packets": 2, "rx_errors": 0, "rx_dropped": 0, "tx_bytes": 84, "tx_packets": 2, "tx_errors": 0, "tx_dropped": 0 } }, "network_rate_stats": { "rx_bytes_per_sec": 0, "tx_bytes_per_sec": 0 } } }