

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

# Amazon EKS 上的 Prometheus 監控
<a name="prometheus-monitoring-eks"></a>

[Amazon Managed Service for Prometheus](https://docs.aws.amazon.com//prometheus/latest/userguide/what-is-Amazon-Managed-Service-Prometheus.html) 為開放原始碼 Prometheus 提供可擴展、安全、受 AWS 管的服務。您可以使用 Prometheus 查詢語言 (PromQL) 來監控容器化工作負載的效能，而無需管理基礎基礎設施來擷取、儲存和查詢操作指標。您可以使用 [AWS Distro for OpenTelemetry (ADOT)](https://docs.aws.amazon.com//prometheus/latest/userguide/AMP-onboard-ingest-metrics-OpenTelemetry.html) 或 Prometheus 伺服器做為收集代理程式，從 Amazon EKS 和 Amazon ECS 收集 Prometheus 指標。

[Prometheus 的 CloudWatch Container Insights 監控](https://docs.aws.amazon.com//AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus.html)可讓您設定和使用 CloudWatch 代理程式，從 Amazon ECS、Amazon EKS 和 Kubernetes 工作負載探索 Prometheus 指標，並將其擷取為 CloudWatch 指標。如果 CloudWatch 是您的主要可觀測性和監控解決方案，則此解決方案是適當的。不過，以下清單概述了 Amazon Managed Service for Prometheus 為擷取、儲存和查詢 Prometheus 指標提供更多彈性的使用案例：
+ Amazon Managed Service for Prometheus 可讓您使用 Amazon EKS 或自我管理 Kubernetes 中部署的現有 Prometheus 伺服器，並將其設定為寫入 Amazon Managed Service for Prometheus，而不是本機設定的資料存放區。這消除了管理 Prometheus 伺服器及其基礎設施高度可用資料存放區的繁重工作。當您想要在 AWS 雲端中利用成熟的 Prometheus 部署時，Amazon Managed Service for Prometheus 是適當的選擇。
+ Grafana 直接支援 Prometheus 做為視覺化的資料來源。如果您想要使用 Grafana 搭配 Prometheus 而非 CloudWatch Dashboards 進行容器監控，則 Amazon Managed Service for Prometheus 可以滿足您的需求。Amazon Managed Service for Prometheus 與 Amazon Managed Grafana 整合，以提供受管的開放原始碼監控和視覺化解決方案。
+ Prometheus 可讓您使用 PromQL 查詢，對操作指標執行分析。相反地，[CloudWatch 代理程式會將內嵌指標格式的 Prometheus 指標擷取](https://docs.aws.amazon.com//AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup-configure-ECS.html#ContainerInsights-Prometheus-Setup-cw-agent-config)至 CloudWatch Logs，進而產生 CloudWatch 指標。您可以使用 CloudWatch Logs Insights 查詢內嵌指標格式日誌。
+ 如果您不打算使用 CloudWatch 進行監控和指標擷取，則應搭配 Prometheus 伺服器和視覺化解決方案使用 Amazon Managed Service for Prometheus，例如 Grafana。您需要將 Prometheus 伺服器設定為從 Prometheus 目標抓取指標，並將伺服器設定為[遠端寫入您的 Amazon Managed Service for Prometheus 工作區](https://docs.aws.amazon.com//prometheus/latest/userguide/AMP-onboard-ingest-metrics-existing-Prometheus.html)。如果您使用 Amazon Managed Grafana，則可以[使用隨附的外掛程式，直接將 Amazon Managed Grafana 與您的 Amazon Managed Service for Prometheus 資料來源整合](https://docs.aws.amazon.com//grafana/latest/userguide/prometheus-data-source.html)。由於指標資料存放在 Amazon Managed Service for Prometheus 中，因此沒有部署 CloudWatch 代理程式或將資料擷取至 CloudWatch 的需求。Prometheus 的 Container Insights 監控需要 CloudWatch 代理程式。

您也可以使用 ADOT 收集器從 Prometheus 檢測的應用程式進行湊集，並將指標傳送至 Amazon Managed Service for Prometheus。如需 ADOT Collector 的詳細資訊，請參閱 [AWS Distro for OpenTelemetry](https://aws.amazon.com/otel/) 文件。