View a markdown version of this page

整合 Amazon EKS - Amazon CloudWatch

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

整合 Amazon EKS

Amazon CloudWatch 受管 Prometheus 收集器會抓取Prometheus與 相容的指標。如需Prometheus相容指標的詳細資訊,請參閱什麼是 Prometheus 相容指標?。Amazon EKS 叢集會公開 API 伺服器的指標。Kubernetes 1.28 版或更新版本的 Amazon EKS 叢集也會公開 kube-scheduler 和 kube-controller-manager 的指標。如需詳細資訊,請參閱《Amazon EKS 使用者指南》中的擷取 Prometheus 格式的控制平面原始指標

Amazon Managed Service for Prometheus 使用者指南提供詳細的設定指示。如需設定 Amazon EKS 叢集、存取項目和 ConfigMap 設定的指示,請參閱設定 Amazon EKS 的受管收集器

注意

收集器會使用識別其原始伺服器的屬性來充實每個 Amazon EKS 指標:檢測範圍、 AWS 帳戶和區域、推斷單位,以及叢集名稱和叢集 ARN。當您使用 PromQL 查詢指標時,可以篩選和分組這些屬性。

使用 CloudWatch 目的地建立抓取器

您可以使用 GetDefaultScraperConfiguration來擷取一般用途的抓取器組態,或提供您自己的組態。

AWS API

使用 CreateScraper API 操作建立具有 CloudWatch 目的地的抓取器。將 AWS 帳戶、安全群組、子網路、Amazon EKS 叢集和資料集資訊取代為您自己的值。

POST /scrapers HTTP/1.1 { "alias": "eks-metrics-scraper", "source": { "eksConfiguration": { "clusterArn": "arn:aws:eks:us-west-2:123456789012:cluster/my-cluster", "securityGroupIds": ["sg-security-group-id"], "subnetIds": ["subnet-subnet-id-1", "subnet-subnet-id-2"] } }, "destination": { "cloudWatchConfiguration": { "datasetArn": "arn:aws:cloudwatch:us-west-2:123456789012:dataset/default" } }, "scrapeConfiguration": { "configurationBlob": "base64-encoded-blob" } }
AWS CLI

使用 create-scraper命令建立具有 CloudWatch 目的地的抓取器。將 AWS 帳戶、安全群組、子網路、Amazon EKS 叢集和資料集資訊取代為您自己的值。

aws amp create-scraper \ --alias "eks-metrics-scraper" \ --source eksConfiguration="{clusterArn='arn:aws:eks:us-west-2:123456789012:cluster/my-cluster', \ securityGroupIds=['sg-security-group-id'], \ subnetIds=['subnet-subnet-id-1','subnet-subnet-id-2']}" \ --scrape-configuration configurationBlob=$(cat eks-config.yaml | base64 -w 0) \ --destination cloudWatchConfiguration="{datasetArn='arn:aws:cloudwatch:us-west-2:123456789012:dataset/default'}"

檢視自動儀表板

收集器開始將 Amazon EKS 指標交付至 CloudWatch 之後,CloudWatch 主控台會提供名為 EKS OTel 的自動儀表板。若要開啟它,請參閱 EKS OTel,或登入 AWS 管理主控台、開啟 CloudWatch 主控台、在導覽窗格中選擇儀表板、選擇自動儀表板,然後選擇 EKS OTel。您可以開始監控叢集,而無需自行建置任何小工具或儀表板。

如果自動儀表板符合您的需求,您可以正常使用它。若要建立量身打造的監控體驗,您可以將其任何小工具新增至自訂儀表板。如需自訂儀表板的詳細資訊,請參閱使用 CloudWatch 儀表板

跨帳戶可觀測性

對於跨帳戶 Amazon EKS 監控,我們建議您使用 Amazon CloudWatch 指標集中。如需詳細資訊,請參閱 CloudWatch 指標集中。

如需其他跨帳戶抓取器組態,請參閱《Amazon Managed Service for Prometheus 使用者指南》中的跨帳戶抓取器