

# Amazon ECS 容器实例运行状况更改事件
<a name="ecs_container_instance_health_events"></a>

以下方案将引起容器实例运行状况更改事件。

**Amazon ECS 容器代理检测容器运行时运行状况的变化。**

容器代理会定期评估容器实例上容器运行时（例如 Docker 进程守护程序）的运行状况。如果运行时无响应或恢复，代理会报告该变化并生成事件。

可用性：EC2 启动类型。

**Amazon ECS 容器代理检测加速计算设备运行状况的变化。**

对于具有加速计算设备（如 GPU）的实例，容器代理会监控设备运行状况。如果设备受损或恢复，则会生成事件。

可用性：Amazon ECS 托管实例启动类型。

**Amazon ECS 容器代理检测进程守护程序运行状况的变化。**

容器代理监控容器实例上所需的进程守护程序任务。如果进程守护程序任务失败，则系统会生成事件。

可用性：Amazon ECS 托管实例启动类型。

**容器实例的整体运行状况发生变化。**

Amazon ECS 根据各项运行状况检查结果计算整体运行状况。当整体状态转换时，系统会生成事件。

可用性：Amazon ECS 托管实例和 EC2 启动类型。

## 示例容器实例运行状况更改事件
<a name="ecs_container_instance_health_events_example"></a>

容器实例运行状况更改事件以以下格式传送。有关参数的更多信息，请参阅用户指南**中的 [Amazon 服务事件元数据](https://docs.amazonaws.cn/eventbridge/latest/userguide/eb-events-structure.html)。

**容器运行时运行状况事件示例**

```
{
    "version": "0",
    "id": "EXAMPLE-48f8-c0ff-0dab-EXAMPLE2ac34",
    "detail-type": "ECS Container Instance Health Change",
    "source": "aws.ecs",
    "account": "123456789012",
    "time": "2026-04-11T00:49:09Z",
    "region": "us-west-2",
    "resources": [
        "arn:aws:ecs:us-west-2:123456789012:container-instance/my-cluster/a1b2c3d4EXAMPLE"
    ],
    "detail": {
        "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/my-cluster",
        "containerInstanceArn": "arn:aws:ecs:us-west-2:123456789012:container-instance/my-cluster/a1b2c3d4EXAMPLE",
        "capacityProviderName": null,
        "ec2InstanceId": "i-0abcdef1234567890",
        "overallStatus": "OK",
        "healthChecks": [
            {
                "type": "CONTAINER_RUNTIME",
                "status": "OK",
                "lastStatusChange": "2026-04-11T00:48:53Z",
                "lastUpdated": "2026-04-11T00:48:09Z",
                "statusReason": null
            }
        ]
    }
}
```

**加速计算运行状况事件示例**

```
{
    "version": "0",
    "id": "EXAMPLE-46c3-a48a-1bef-EXAMPLE72f3c",
    "detail-type": "ECS Container Instance Health Change",
    "source": "aws.ecs",
    "account": "123456789012",
    "time": "2026-04-11T00:49:09Z",
    "region": "us-west-2",
    "resources": [
        "arn:aws:ecs:us-west-2:123456789012:container-instance/my-cluster/a1b2c3d4EXAMPLE"
    ],
    "detail": {
        "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/my-cluster",
        "containerInstanceArn": "arn:aws:ecs:us-west-2:123456789012:container-instance/my-cluster/a1b2c3d4EXAMPLE",
        "capacityProviderName": "my-capacity-provider",
        "ec2InstanceId": "i-0abcdef1234567890",
        "overallStatus": "IMPAIRED",
        "healthChecks": [
            {
                "type": "ACCELERATED_COMPUTE",
                "status": "IMPAIRED",
                "lastStatusChange": "2026-04-11T00:48:53Z",
                "lastUpdated": "2026-04-11T00:48:09Z",
                "statusReason": "XID_46"
            }
        ]
    }
}
```

**进程守护程序运行状况事件示例**

```
{
    "version": "0",
    "id": "EXAMPLE-febc-b5e3-054b-EXAMPLE1a1f4f",
    "detail-type": "ECS Container Instance Health Change",
    "source": "aws.ecs",
    "account": "123456789012",
    "time": "2026-04-11T00:49:09Z",
    "region": "us-west-2",
    "resources": [
        "arn:aws:ecs:us-west-2:123456789012:container-instance/my-cluster/a1b2c3d4EXAMPLE"
    ],
    "detail": {
        "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/my-cluster",
        "containerInstanceArn": "arn:aws:ecs:us-west-2:123456789012:container-instance/my-cluster/a1b2c3d4EXAMPLE",
        "capacityProviderName": "my-capacity-provider",
        "ec2InstanceId": "i-0abcdef1234567890",
        "overallStatus": "IMPAIRED",
        "healthChecks": [
            {
                "type": "DAEMON",
                "status": "IMPAIRED",
                "lastStatusChange": "2026-04-11T00:48:53Z",
                "lastUpdated": "2026-04-11T00:48:09Z",
                "statusReason": "Daemon task: EXAMPLE-4af2-4b3c-b9c1-EXAMPLEb2bbf is unhealthy"
            }
        ]
    }
}
```