

 **協助改進此頁面** 

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

若要為本使用者指南貢獻內容，請點選每個頁面右側面板中的**在 GitHub 上編輯此頁面**連結。

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

# 藉助 Prometheus 監控叢集指標
<a name="prometheus"></a>

 [Prometheus](https://prometheus.io/) 是湊集端點的監控和時間序列資料庫。它提供查詢、彙總和儲存收集之資料的能力。您也可以將其用於警示和警示彙總。本主題說明如何將 Prometheus 設定為受管或開放原始碼選項。監控 Amazon EKS 控制平面指標是常見的使用案例。

Amazon Managed Service for Prometheus 是與 Prometheus 相容的監控和提示服務，可讓您輕鬆地大規模監控容器化應用程式和基礎設施。這是一項全受管服務，既可自動擴展指標的擷取、儲存、查詢和提醒，也可以與 AWS 安全服務整合，以便快速且安全地存取資料。您可以使用開放原始碼 PromQL 查詢語言來查詢指標並根據指標發出提醒。此外，您還可藉助 Amazon Managed Service for Prometheus 中的提醒管理員，為關鍵提醒設定提醒規則。您隨後可將這些關鍵提醒作為通知傳送至 Amazon SNS 主題。

提供了多種不同的選項來將 Prometheus 與 Amazon EKS 配合使用：
+ 您可在首次建立 Amazon EKS 叢集時，開啟 Prometheus 指標，或者針對現有的叢集建立自己的 Prometheus 湊集器。本主題將介紹這兩個選項。
+ 您可使用 Helm 來部署 Prometheus。如需詳細資訊，請參閱 [使用 Helm 部署 Prometheus](deploy-prometheus.md)。
+ 您能夠以 Prometheus 格式來檢視控制平面原始指標。如需詳細資訊，請參閱 [擷取採用 Prometheus 格式的控制平面原始指標](view-raw-metrics.md)。

## 步驟 1：開啟 Prometheus 指標
<a name="turn-on-prometheus-metrics"></a>

**重要**  
叢集生命週期不包括適用於 Prometheus 的 Amazon Managed Service 資源，需要獨立於叢集進行維護。刪除叢集後，確認亦同時刪除任何適用的湊集器，以免產生適用的費用。如需詳細資訊，請參閱 *Amazon Managed Service for Prometheus 使用者指南*中的[尋找及刪除湊集器](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html#AMP-collector-list-delete)。

Prometheus 透過稱為湊集的提取型模式，從您的叢集中探索並收集指標。湊集器的設定是為了從您的叢集基礎設施和容器化應用程式收集資料。當您開啟傳送 Prometheus 指標的選項時，Amazon Managed Service for Prometheus 會提供完全受管的無代理程式湊集器。

若尚未建立叢集，您可在首次建立叢集時，開啟將指標傳送至 Prometheus 的選項。在 Amazon EKS 主控台中，此選項位於建立新叢集的**設定可觀測性步驟**中。如需詳細資訊，請參閱 [建立 Amazon EKS 叢集](create-cluster.md)。

若目前已有叢集，您可建立自己的 Prometheus 湊集器。如需在 Amazon EKS 主控台執行此動作，導覽至叢集的**可觀測性**索引標籤，然後選擇**新增湊集器**按鈕。若您想透過 AWS API 或 AWS CLI 執行此動作，請參閱*適用於 Prometheus 的 Amazon Managed Service 使用者指南*中的[建立湊集器](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html#AMP-collector-create)。

透過 Amazon EKS 主控台建立湊集器時，以下選項可供使用。

 **湊集器別名**   
(選用) 輸入湊集器的唯一別名。

 **目的地**   
選擇 Amazon Managed Service for Prometheus 工作區。工作區是專門用於儲存和查詢 Prometheus 指標的邏輯空間。使用此工作區，您能夠跨具有該工作區存取權的帳戶檢視 Prometheus 指標。**建立新工作區**選項會讓 Amazon EKS 知道可以使用您提供的**工作區別名**來代表您建立工作區。使用**選取現有工作區**選項，您可以從下拉式清單中選取現有的工作區。如需工作區的詳細資訊，請參閱《*Amazon Managed Service for Prometheus 使用者指南*》中的[管理工作區](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-manage-ingest-query.html)。

 **服務存取**   
本節總結您在傳送 Prometheus 指標時授予的許可：  
+ 允許 Amazon Managed Service for Prometheus 描述湊集的 Amazon EKS 叢集
+ 允許遠端寫入 Amazon 受管 Prometheus 工作區
如果 `AmazonManagedScraperRole` 已經存在，則湊集器會使用它。選擇 `AmazonManagedScraperRole` 連結以查看**許可詳細資訊**。如果 `AmazonManagedScraperRole` 尚未存在，請選擇**檢視許可詳細資訊**連結，以查看您透過傳送 Prometheus 指標來授予的特定許可。

 **子網路**   
修改湊集器會視需繼承的子網路。若您需要新增呈現灰色的子網路選項，請返回建立叢集**指定聯網**步驟。

 **湊集器組態**   
視需要修改 YAML 格式的湊集器組態。若要執行這項操作，請使用表單或上傳取代 YAML 檔案。如需詳細資訊，請參閱《*Amazon Managed Service for Prometheus 使用者指南*》中的[湊集器組態](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html#AMP-collector-configuration)。

Amazon Managed Service for Prometheus 是指作為 AWS 受管收集器與叢集一起建立的無代理程式湊集器。若要了解 AWS 受管收集器的相關詳細資訊，請參閱*適用於 Prometheus 的 Amazon Managed Service 使用者指南*中的[透過 AWS 受管收集器來擷取指標](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector.html)。

**重要**  
若使用 AWS CLI 或 AWS API 建立 Prometheus 湊集器，需要調整其組態，以授予湊集器叢集內許可。如需詳細資訊，請參閱《*Amazon Managed Service for Prometheus 使用者指南*》中的[設定 Amazon EKS 叢集](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html#AMP-collector-eks-setup)。
若在 2024 年 11 月 11 日之前建立 Prometheus 湊集器，且使用 `aws-auth` `ConfigMap` 而非存取項目，您需要進行更新，才可透過 Amazon EKS 叢集控制平面來存取額外的指標。若要了解更新的組態，請參閱*適用於 Prometheus 的 Amazon Managed Service 使用者指南*中的[手動設定 Amazon EKS 的湊集器存取權](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html#AMP-collector-eks-manual-setup)。

## 步驟 2：使用 Prometheus 指標
<a name="use-prometheus-metrics"></a>

若要了解如何在為叢集開啟 Prometheus 指標後使用該指標的相關詳細資訊，請參閱[適用於 Prometheus 的 Amazon Managed Service 使用者指南](https://docs.aws.amazon.com/prometheus/latest/userguide/what-is-Amazon-Managed-Service-Prometheus.html)。

## 步驟 3：管理 Prometheus 湊集器
<a name="viewing-prometheus-scraper-details"></a>

如需管理湊集器，在 Amazon EKS 主控台中，選擇**可觀測性**索引標籤。表格會顯示叢集的湊集器清單，包含湊集器 ID、別名、狀態和建立日期等資訊。您可新增更多湊集器、編輯湊集器、刪除湊集器，或者檢視目前湊集器的相關詳細資訊。

如需檢視湊集器的相關詳細資訊，請選擇湊集器 ID 連結。舉例來說，您可檢視 ARN、環境、工作區 ID、IAM 角色、組態，以及聯網資訊。您可使用湊集器 ID 作為輸入到 Amazon Managed Service for Prometheus API 操作 (例如 [https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DescribeScraper.html](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DescribeScraper.html)、[https://docs.aws.amazon.com/prometheus/latest/APIReference/API_UpdateScraper.html](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_UpdateScraper.html) 及 [https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DeleteScraper.html](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DeleteScraper.html))。若要了解使用 Prometheus API 的相關詳細資訊，請參閱[適用於 Prometheus 的 Amazon Managed Service API 參考](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-APIReference.html)。