

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

# Amazon EKS 集群的运行时覆盖率和故障排除
<a name="eks-runtime-monitoring-coverage"></a>

启用运行时监控并手动或通过自动代理配置为 EKS 安装 GuardDuty 安全代理（附加组件）后，您可以开始评估 EKS 集群的覆盖范围。

**Topics**
+ [查看覆盖率统计数据](#reviewing-coverage-statistics-eks-runtime-monitoring)
+ [保险状态会随着 EventBridge 通知而发生变化](#eks-runtime-monitoring-coverage-status-change)
+ [对 Amazon EKS 运行时覆盖率问题故障排除](#eks-runtime-monitoring-coverage-issues-troubleshoot)

## 查看覆盖率统计数据
<a name="reviewing-coverage-statistics-eks-runtime-monitoring"></a>

与您自己的账户或成员账户关联的 EKS 集群的覆盖率统计数据，指的是正常 EKS 集群占选定 AWS 区域环境中所有 EKS 集群的百分比。下式将其表示为：

*（健康 clusters/All 集群）\$1100*

选择一种访问方法来查看您账户的覆盖率统计数据。

------
#### [ Console ]
+ 登录 AWS 管理控制台 并打开 GuardDuty 控制台，网址为[https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/)。
+ 在导航窗格中，选择**运行时监控**。
+ 选择 **EKS 集群运行时覆盖范围**选项卡。
+ 在 **EKS 集群运行时覆盖范围**选项卡下，您可以查看按**集群列表**表中可用的覆盖状态汇总的覆盖率统计数据。
  + 您可以按以下列筛选**集群列表**表：
    + **集群名称**
    + **账户 ID**
    + **代理管理类型**
    + **覆盖状态**
    + **插件版本**
+ 如果您的任何 EKS 集群的**覆盖状态**为**不正常**，则**问题**列可能包含有关**不正常**状态原因的其他信息。

------
#### [ API/CLI ]
+ 使用您自己的有效检测器 ID、区域和服务端点运行 [ListCoverage](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListCoverage.html)API。您可以使用此 API 对集群列表进行筛选和排序。
  + 您可以使用以下 `CriterionKey` 选项之一更改示例 `filter-criteria`：
    + `ACCOUNT_ID`
    + `CLUSTER_NAME`
    + `RESOURCE_TYPE`
    + `COVERAGE_STATUS`
    + `ADDON_VERSION`
    + `MANAGEMENT_TYPE`
  + 您可以使用以下选项更改 `sort-criteria` 中的示例 `AttributeName`：
    + `ACCOUNT_ID`
    + `CLUSTER_NAME`
    + `COVERAGE_STATUS`
    + `ISSUE`
    + `ADDON_VERSION`
    + `UPDATED_AT`
  + 您可以更改*max-results*（最多 50 个）。
  + 要查找您的账户和当前区域的，请查看[https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/)控制台中的 **“设置**” 页面，或者运行 [https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html)API。`detectorId`

  ```
  aws guardduty --region us-east-1 list-coverage --detector-id 12abc34d567e8fa901bc2d34e56789f0 --sort-criteria '{"AttributeName": "EKS_CLUSTER_NAME", "OrderBy": "DESC"}' --filter-criteria '{"FilterCriterion":[{"CriterionKey":"ACCOUNT_ID", "FilterCondition":{"EqualsValue":"111122223333"}}] }'  --max-results 5
  ```
+ 运行 [GetCoverageStatistics](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_GetCoverageStatistics.html)API 以检索基于的覆盖率汇总统计信息`statisticsType`。
  + 您可以使用以下选项之一更改示例 `statisticsType`：
    + `COUNT_BY_COVERAGE_STATUS`：表示按覆盖状态汇总的 EKS 集群的覆盖率统计数据。
    + `COUNT_BY_RESOURCE_TYPE`— 根据列表中的 AWS 资源类型汇总的覆盖率统计信息。
    + 您可以在命令中更改示例 `filter-criteria`。您可以对 `CriterionKey` 使用以下选项：
      + `ACCOUNT_ID`
      + `CLUSTER_NAME`
      + `RESOURCE_TYPE`
      + `COVERAGE_STATUS`
      + `ADDON_VERSION`
      + `MANAGEMENT_TYPE`
  + 要查找您的账户和当前区域的，请查看[https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/)控制台中的 **“设置**” 页面，或者运行 [https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html)API。`detectorId`

  ```
  aws guardduty --region us-east-1 get-coverage-statistics --detector-id 12abc34d567e8fa901bc2d34e56789f0 --statistics-type COUNT_BY_COVERAGE_STATUS --filter-criteria '{"FilterCriterion":[{"CriterionKey":"ACCOUNT_ID", "FilterCondition":{"EqualsValue":"123456789012"}}] }'
  ```

------

如果您的 EKS 集群的覆盖状态为**不正常**，请参阅 [对 Amazon EKS 运行时覆盖率问题故障排除](#eks-runtime-monitoring-coverage-issues-troubleshoot)。

## 保险状态会随着 EventBridge 通知而发生变化
<a name="eks-runtime-monitoring-coverage-status-change"></a>

您账户中 EKS 集群的覆盖状态可能显示为**不正常**。要检测覆盖状态何时变为**不正常**，我们建议您定期监控覆盖状态，并在状态变为**不正常**时进行问题排查。或者，您可以创建 Amazon EventBridge 规则，以便在保险状态从变`Unhealthy`为`Healthy`或其他状态时通知您。默认情况下，会在[EventBridge 公交车](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-bus.html)上为您的账户 GuardDuty 发布此内容。

### 示例通知架构
<a name="coverage-status-eventbridge-schema"></a>

在 EventBridge 规则中，您可以使用预定义的示例事件和事件模式来接收覆盖状态通知。有关创建 EventBridge 规则的更多信息，请参阅 *Amazon EventBridge 用户指南*中的[创建规则](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-get-started.html#eb-gs-create-rule)。

此外，您还可以使用以下示例通知架构来创建自定义事件模式。确保替换账户的值。要在您的 Amazon EKS 集群的覆盖状态从变`Healthy`为时收到通知`Unhealthy`，`detail-type`应该是*GuardDuty Runtime Protection Unhealthy*。要在保险状态从变为时收到通知`Healthy`，`Unhealthy`请将的`detail-type`值替换为*GuardDuty Runtime Protection Healthy*。

```
{
  "version": "0",
  "id": "event ID",
  "detail-type": "GuardDuty Runtime Protection Unhealthy",
  "source": "aws.guardduty",
  "account": "AWS 账户 ID",
  "time": "event timestamp (string)",
  "region": "AWS 区域",
  "resources": [
       ],
  "detail": {
    "schemaVersion": "1.0",
    "resourceAccountId": "string",
    "currentStatus": "string",
    "previousStatus": "string",
    "resourceDetails": {
        "resourceType": "EKS",
        "eksClusterDetails": { 
            "clusterName": "string",
            "availableNodes": "string",
             "desiredNodes": "string",
             "addonVersion": "string"
         }
    },
    "issue": "string",
    "lastUpdatedAt": "timestamp"
  }
}
```

## 对 Amazon EKS 运行时覆盖率问题故障排除
<a name="eks-runtime-monitoring-coverage-issues-troubleshoot"></a>

如果您的 EKS 集群的覆盖状态为`Unhealthy`，则可以在 GuardDuty 控制台的 “**问题**” 列下或使用[CoverageResource](https://docs.aws.amazon.com/guardduty/latest/APIReference/API_CoverageResource.html)数据类型查看相应的错误。

在使用包含或排除标签有选择地监控 EKS 集群时，标签可能需要一些时间才能同步。这可能会影响关联 EKS 集群的覆盖状态。您可以再次尝试删除并添加相应的标签（包含或排除）。有关更多信息，请参阅《Amazon EKS 用户指南》****中的[标记 Amazon EKS 资源](https://docs.aws.amazon.com/eks/latest/userguide/eks-using-tags.html)。

覆盖问题的结构是 `Issue type:Extra information`。通常，问题会有一个可选的*额外信息*，其中可能包括特定的客户端异常或有关问题的描述。根据*额外信息*，下表提供了对 EKS 集群的覆盖问题进行故障排除的建议步骤。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/eks-runtime-monitoring-coverage.html)


**使用插件问题代码解决插件 creation/updation 错误的步骤**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/eks-runtime-monitoring-coverage.html)