

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

# 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 叢集中所佔百分比。可以用下列方程式將此表示為：

*(運作狀態良好的叢集/所有叢集) \$1 100*

選擇其中一種存取方法來檢閱您帳戶的涵蓋範圍統計資料。

------
#### [ Console ]
+ 登入 AWS 管理主控台 ，並在 [https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/)：// 開啟 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 個)。
  + 若要尋找`detectorId`您帳戶和目前區域的 ，請參閱 [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。

  ```
  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`
  + 若要尋找`detectorId`您帳戶和目前區域的 ，請參閱 [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。

  ```
  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` 或其他狀態時通知您。GuardDuty 預設在您帳戶的[EventBridge 匯流排](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-bus.html)中發布此通知。

### 範例通知結構描述
<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*。若要在涵蓋範圍狀態從 `Unhealthy` 變更成 `Healthy` 時收到通知，請使用 *GuardDuty 執行期監控運作狀態不良*取代 `detail-type` 的值。

```
{
  "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 ECS 使用者指南》****中的[為您的 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_tw/guardduty/latest/ug/eks-runtime-monitoring-coverage.html)


**使用附加元件問題碼對附加元件建立/更新錯誤的步驟進行故障診斷**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/guardduty/latest/ug/eks-runtime-monitoring-coverage.html)