

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

# 使用 AWS 受管收集器擷取指標
<a name="AMP-collector"></a>

Amazon Managed Service for Prometheus 的常見使用案例是監控 Amazon Elastic Kubernetes Service (Amazon EKS) 管理的 Kubernetes 叢集。Kubernetes 叢集和 Amazon EKS 內執行的許多應用程式會自動匯出其指標，以供與 Prometheus 相容的湊集器存取。

**注意**  
Amazon EKS 會在叢集中公開 API 伺服器指標、`kube-controller-manager`指標和`kube-scheduler`指標。在 Kubernetes 環境中執行的許多其他技術和應用程式提供 Prometheus 相容指標。如需可用匯出工具的完整清單，請參閱 Prometheus 說明文件中的[匯出工具和整合](https://prometheus.io/docs/instrumenting/exporters/)。

Amazon Managed Service for Prometheus 提供全受管、代理程式較少的抓取器或*收集器*，可自動探索和提取與 Prometheus 相容的指標。您無需管理、安裝、修補或維護代理程式或湊集器。Amazon Managed Service for Prometheus 收集器可為您的 Amazon EKS 叢集提供可靠、穩定、高可用性、自動擴展的指標集合。Amazon Managed Service for Prometheus 受管收集器可與 Amazon EKS 叢集搭配使用，包括 EC2 和 Fargate。

Amazon Managed Service for Prometheus 收集器會在建立湊集器時，為指定的每個子網路建立彈性網路介面 (ENI)。收集器會透過這些 ENI 湊集指標，並使用 `remote_write` 將資料推送到使用 VPC 端點的 Amazon Managed Service for Prometheus 工作區。湊集的資料永遠不會在公有網際網路上傳輸。

下列主題提供有關如何在 Amazon EKS 叢集中使用 Amazon Managed Service for Prometheus 收集器，以及所收集指標的詳細資訊。

**Topics**
+ [設定 Amazon EKS 的受管收集器](AMP-collector-how-to.md)
+ [設定 Amazon MSK 的受管 Prometheus 收集器](prom-msk-integration.md)
+ [什麼是與 Prometheus 相容的指標？](prom-compatible-metrics.md)
+ [使用付費日誌監控收集器](AMP-collector-vended-logs.md)

# 設定 Amazon EKS 的受管收集器
<a name="AMP-collector-how-to"></a>

若要使用 Amazon Managed Service for Prometheus 收集器，您可以建立抓取器來探索和提取 Amazon EKS 叢集中的指標。您也可以建立與 Amazon Managed Streaming for Apache Kafka 整合的抓取器。如需詳細資訊，請參閱[整合 Amazon MSK](https://docs.aws.amazon.com/prometheus/latest/userguide/prom-msk-integration.html)。
+ 您可以建立湊集器作為 Amazon EKS 叢集建立作業的一部份。如需建立 Amazon EKS 叢集的詳細資訊，包括建立抓取器，請參閱《[Amazon EKS 使用者指南》中的建立 Amazon EKS 叢集](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)。 **
+ 您可以使用 AWS API 或使用 ，以程式設計方式建立自己的抓取器 AWS CLI。

Amazon Managed Service for Prometheus 收集器會抓取與 Prometheus 相容的指標。如需 Prometheus 相容指標的詳細資訊，請參閱 [什麼是與 Prometheus 相容的指標？](prom-compatible-metrics.md)。Amazon EKS 叢集會公開 API 伺服器的指標。Kubernetes 版本`1.28`或更高版本的 Amazon EKS 叢集也會公開 `kube-scheduler`和 的指標`kube-controller-manager`。如需詳細資訊，請參閱《*Amazon EKS 使用者指南*》中的[擷取 Prometheus 格式的控制平面原始指標](https://docs.aws.amazon.com/eks/latest/userguide/view-raw-metrics.html#scheduler-controller-metrics)。

**注意**  
從叢集擴展指標可能會產生網路用量的費用。最佳化這些成本的一種方法是設定您的`/metrics`端點來壓縮提供的指標 （例如，使用 gzip)，以減少必須跨網路移動的資料。如何執行此操作取決於提供指標的應用程式或程式庫。根據預設，某些程式庫 gzip。

下列主題說明如何建立、管理和設定湊集器。

**Topics**
+ [建立湊集器](#AMP-collector-create)
+ [設定 Amazon EKS 叢集](#AMP-collector-eks-setup)
+ [尋找並刪除湊集器](#AMP-collector-list-delete)
+ [湊集器組態](#AMP-collector-configuration)
+ [對湊集器組態進行移難排解](#AMP-collector-troubleshoot)
+ [湊集器限制](#AMP-collector-limits)

## 建立湊集器
<a name="AMP-collector-create"></a>

Amazon Managed Service for Prometheus 收集器包含一個湊集器，可從 Amazon EKS 叢集中探索和收集指標。Amazon Managed Service for Prometheus 可為您管理湊集器，提供所需的可擴展性、安全性和可靠性，而無需自行管理任何執行個體、代理程式或湊集器。

建立抓取器的方法有三種：
+ 當您[透過 Amazon EKS 主控台建立 Amazon EKS 叢集](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)並選擇開啟 Prometheus 指標時，系統會自動為您建立抓取器。
+ 您可以從 Amazon EKS 主控台為現有叢集建立抓取器。在 [Amazon EKS 主控台](https://console.aws.amazon.com/eks/home#/clusters)中開啟叢集，然後在**可觀測性**索引標籤上，選擇**新增抓取器**。

  如需可用設定的詳細資訊，請參閱《*Amazon EKS 使用者指南*》中的[開啟 Prometheus 指標](https://docs.aws.amazon.com/eks/latest/userguide/prometheus.html#turn-on-prometheus-metrics)。
+ 您可以使用 AWS API 或 建立抓取器 AWS CLI。

  這些選項會在下列程序中說明。

您需先滿足幾項先決條件，才能建立自己的湊集器：
+ 您必須已建立 Amazon EKS 叢集。
+ 您的 Amazon EKS 叢集必須設定[叢集端點存取控制](https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html)以包含私有存取。它可以包括私有和公有，但必須包含私有。
+ Amazon EKS 叢集所在的 Amazon VPC 必須[啟用 DNS](https://docs.aws.amazon.com/vpc/latest/userguide/AmazonDNS-concepts.html)。

**注意**  
叢集將依其 Amazon 資源名稱 (ARN) 與抓取器建立關聯。如果您刪除叢集，然後使用相同名稱建立新的叢集，則 ARN 將重複使用於新叢集。因此，抓取器會嘗試收集新叢集的指標。[您可以將抓取器](#AMP-collector-list-delete)與刪除叢集分開刪除。

------
#### [ AWS API ]

**使用 AWS API 建立 **

使用 `CreateScraper` API 操作來建立具有 AWS API 的抓取器。以下範例會在 `us-west-2` 地區中建立湊集器。您需要使用自己的 ID 取代 AWS 帳戶、工作區、安全性和 Amazon EKS 叢集資訊，並提供用於湊集器的組態。

**注意**  
安全群組和子網路應設定為您要連線之叢集的安全群組和子網路。  
您必須包含至少兩個子網路，至少位於兩個可用區域。

`scrapeConfiguration` 是一個 base64 編碼的 Prometheus 組態 YAML 檔案。您可以透過 `GetDefaultScraperConfiguration` API 作業下載一般用途設定。如需 的格式詳細資訊`scrapeConfiguration`，請參閱 [湊集器組態](#AMP-collector-configuration)。

```
POST /scrapers HTTP/1.1
Content-Length: 415 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: aws-cli/1.18.147 Python/2.7.18 Linux/5.4.58-37.125.amzn2int.x86_64 botocore/1.18.6

{
    "alias": "myScraper",
    "destination":  {
        "ampConfiguration": {
            "workspaceArn": "arn:aws:aps:us-west-2:account-id:workspace/ws-workspace-id"
        }
    },
    "source": {
        "eksConfiguration": {
            "clusterArn": "arn:aws:eks:us-west-2:account-id:cluster/cluster-name",
            "securityGroupIds": ["sg-security-group-id"],
            "subnetIds": ["subnet-subnet-id-1", "subnet-subnet-id-2"]
        }
    },
    "scrapeConfiguration": {
        "configurationBlob": <base64-encoded-blob>
    }
}
```

------
#### [ AWS CLI ]

**使用 AWS CLI建立湊集器**

使用 `create-scraper`命令來建立具有 的抓取器 AWS CLI。以下範例會在 `us-west-2` 地區中建立湊集器。您需要使用自己的 ID 取代 AWS 帳戶、工作區、安全性和 Amazon EKS 叢集資訊，並提供用於湊集器的組態。

**注意**  
安全群組和子網路應設定為您要連線之叢集的安全群組和子網路。  
您必須包含至少兩個子網路，至少位於兩個可用區域。

`scrape-configuration` 是一個 base64 編碼的 Prometheus 組態 YAML 檔案。您可以使用 `get-default-scraper-configuration`命令下載一般用途組態。如需 的格式詳細資訊`scrape-configuration`，請參閱 [湊集器組態](#AMP-collector-configuration)。

```
aws amp create-scraper \
  --source eksConfiguration="{clusterArn='arn:aws:eks:us-west-2:account-id:cluster/cluster-name', securityGroupIds=['sg-security-group-id'],subnetIds=['subnet-subnet-id-1', 'subnet-subnet-id-2']}" \
  --scrape-configuration configurationBlob=<base64-encoded-blob> \
  --destination ampConfiguration="{workspaceArn='arn:aws:aps:us-west-2:account-id:workspace/ws-workspace-id'}"
```

------

下列是您可以與 AWS API 一併使用的完整湊集器作業清單：
+ 使用 [CreateScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_CreateScraper.html) API 操作建立抓取器。
+ 使用 [ListScrapers](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_ListScrapers.html) API 操作列出現有的抓取器。
+ 使用 [UpdateScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_UpdateScraper.html) API 操作更新抓取器的別名、組態或目的地。
+ 使用 [DeleteScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DeleteScraper.html) API 操作刪除抓取器。
+ 使用 [DescribeScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DescribeScraper.html) API 操作取得有關抓取器的詳細資訊。
+ 使用 [GetDefaultScraperConfiguration](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_GetDefaultScraperConfiguration.html) API 操作取得抓取器的一般用途組態。

**注意**  
必須設定您要湊集的 Amazon EKS 叢集以讓 Amazon Managed Service for Prometheus 存取指標。下一個主題說明如何設定叢集。

### 跨帳戶設定
<a name="cross-account-remote-write"></a>

若要在 Amazon EKS 叢集和 Amazon Managed Service for Prometheus 工作區位於不同帳戶時建立跨帳戶抓取器，請使用下列程序。例如，您有`account_id_source`包含 Amazon EKS 叢集的來源帳戶，以及`account_id_target`包含 Amazon Managed Service for Prometheus 工作區的目標帳戶。

**在跨帳戶設定中建立抓取器**

1. 在來源帳戶中，建立角色`arn:aws:iam::account_id_source:role/Source`並新增下列信任政策。

   ```
   {
       "Effect": "Allow",
       "Principal": {
       "Service": [
           "scraper.aps.amazonaws.com"
        ]
       },
       "Action": "sts:AssumeRole",
       "Condition": {
           "ArnEquals": {
               "aws:SourceArn": "scraper_ARN"
           },
           "StringEquals": {
               "AWS:SourceAccount": "account_id"
           }
       }
   }
   ```

1. 在來源 (Amazon EKS 叢集） 和目標 (Amazon Managed Service for Prometheus 工作區） 的每個組合上，您需要建立角色，`arn:aws:iam::account_id_target:role/Target`並新增具有 [AmazonPrometheusRemoteWriteAccess](https://docs.aws.amazon.com/prometheus/latest/userguide/security-iam-awsmanpol.html) 許可的下列信任政策。

   ```
   {
     "Effect": "Allow",
     "Principal": {
        "AWS": "arn:aws:iam::account_id_source:role/Source"
     },
     "Action": "sts:AssumeRole",
     "Condition": {
        "StringEquals": {
           "sts:ExternalId": "scraper_ARN"
         }
     }
   }
   ```

1. 使用 `--role-configuration`選項建立抓取器。

   ```
   aws amp create-scraper \
     --source eksConfiguration="{clusterArn='arn:aws:eks:us-west-2:account-id_source:cluster/xarw,subnetIds=[subnet-subnet-id]}" \
     --scrape-configuration configurationBlob=<base64-encoded-blob> \
     --destination ampConfiguration="{workspaceArn='arn:aws:aps:us-west-2:account-id_target:workspace/ws-workspace-id'}"\
     --role-configuration '{"sourceRoleArn":"arn:aws:iam::account-id_source:role/Source", "targetRoleArn":"arn:aws:iam::account-id_target:role/Target"}'
   ```

1. 驗證抓取器建立。

   ```
   aws amp list-scrapers
   {
       "scrapers": [
           {
               "scraperId": "scraper-id",
               "arn": "arn:aws:aps:us-west-2:account_id_source:scraper/scraper-id",
               "roleArn": "arn:aws:iam::account_id_source:role/aws-service-role/scraper.aps.amazonaws.com/AWSServiceRoleForAmazonPrometheusScraperInternal_cc319052-41a3-4",
               "status": {
                   "statusCode": "ACTIVE"
               },
               "createdAt": "2024-10-29T16:37:58.789000+00:00",
               "lastModifiedAt": "2024-10-29T16:55:17.085000+00:00",
               "tags": {},
               "source": {
                   "eksConfiguration": {
                       "clusterArn": "arn:aws:eks:us-west-2:account_id_source:cluster/xarw",
                       "securityGroupIds": [
                           "sg-security-group-id",
                           "sg-security-group-id"
                       ],
                       "subnetIds": [
                           "subnet-subnet_id"
                       ]
                   }
               },
               "destination": {
                   "ampConfiguration": {
                       "workspaceArn": "arn:aws:aps:us-west-2:account_id_target:workspace/ws-workspace-id"
                   }
               }
           }
       ]
   }
   ```

### 在 RoleConfiguration 和服務連結角色之間變更
<a name="changing-roles"></a>

當您想要切換回服務連結角色，而不是 `RoleConfiguration` 以寫入 Amazon Managed Service for Prometheus 工作區時，您必須更新 ，`UpdateScraper`並在與抓取器相同的帳戶中提供工作區，而不使用 `RoleConfiguration`。`RoleConfiguration` 將從抓取器中移除，並使用服務連結角色。

當您變更與抓取器相同帳戶中的工作區，並且想要繼續使用 時`RoleConfiguration`，您必須再次`RoleConfiguration`在 上提供 `UpdateScraper`。

### 為使用客戶受管金鑰啟用的工作區建立抓取器
<a name="setup-customer-managed-keys"></a>

若要建立抓取器，以使用[客戶受管金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk)將指標擷取至 Amazon Managed Service for Prometheus 工作區，請使用同時將來源和目標設定為相同帳戶`--role-configuration`的 。

```
aws amp create-scraper \
  --source eksConfiguration="{clusterArn='arn:aws:eks:us-west-2:account-id:cluster/xarw,subnetIds=[subnet-subnet_id]}" \
  --scrape-configuration configurationBlob=<base64-encoded-blob> \
  --destination ampConfiguration="{workspaceArn='arn:aws:aps:us-west-2:account-id:workspace/ws-workspace-id'}"\
  --role-configuration '{"sourceRoleArn":"arn:aws:iam::account_id:role/Source", "targetRoleArn":"arn:aws:iam::account_id:role/Target"}'
```

### 建立抓取器時的常見錯誤
<a name="AMP-collector-create-errors"></a>

以下是嘗試建立新的抓取器時最常見的問題。
+ 所需的 AWS 資源不存在。指定的*安全群組*、*子網路*和 *Amazon EKS 叢集*必須存在。
+ IP 地址空間不足。您必須在每個傳入 `CreateScraper` API 的子網路中至少有一個可用的 IP 地址。

## 設定 Amazon EKS 叢集
<a name="AMP-collector-eks-setup"></a>

必須設定您的 Amazon EKS 叢集以讓湊集器存取指標。此組態有兩個選項：
+ 使用 Amazon EKS *存取項目*自動提供叢集的 Amazon Managed Service for Prometheus 收集器存取權。
+ 手動設定 Amazon EKS 叢集以進行受管指標抓取。

下列主題會更詳細地說明這些主題。

### 使用存取項目為抓取器存取設定 Amazon EKS
<a name="AMP-collector-eks-access-entry-setup"></a>

使用 Amazon EKS 的存取項目是讓 Amazon Managed Service for Prometheus 存取叢集的湊集指標最簡單的方式。

您抓取的 Amazon EKS 叢集必須設定為允許 API 身分驗證。叢集身分驗證模式必須設定為 `API`或 `API_AND_CONFIG_MAP`。這可在叢集詳細資訊的**存取組態**索引標籤上的 Amazon EKS 主控台中檢視。如需詳細資訊，請參閱《[Amazon EKS 使用者指南》中的允許 IAM 角色或使用者存取 Amazon EKS 叢集上的 Kubernetes 物件](https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html)。 **

您可以在建立叢集時或在建立叢集之後建立抓取器：
+ **建立叢集時** – 當您[透過 Amazon EKS 主控台建立 Amazon EKS 叢集](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)時，您可以設定此存取 （遵循指示來建立叢集中的抓取器），系統會自動建立存取項目政策，讓 Amazon Managed Service for Prometheus 存取叢集指標。
+ **建立叢集後新增 **- 如果您的 Amazon EKS 叢集已存在，請將身分驗證模式設定為 `API`或 `API_AND_CONFIG_MAP`，而您[透過 Amazon Managed Service for Prometheus API 或 CLI](#AMP-collector-create) 或透過 Amazon EKS 主控台建立的任何抓取器，將自動擁有為您建立的正確存取項目政策，抓取器將可存取您的叢集。

**已建立存取項目政策**

當您建立抓取器並讓 Amazon Managed Service for Prometheus 為您產生存取項目政策時，會產生下列政策。如需存取項目的詳細資訊，請參閱[《Amazon EKS 使用者指南》中的允許 IAM 角色或使用者存取 Kubernetes](https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html)。 **

```
{
    "rules": [
        {
            "effect": "allow",
            "apiGroups": [
                ""
            ],
            "resources": [
                "nodes",
                "nodes/proxy",
                "nodes/metrics",
                "services",
                "endpoints",
                "pods",
                "ingresses",
                "configmaps"
            ],
            "verbs": [
                "get",
                "list",
                "watch"
            ]
        },
        {
            "effect": "allow",
            "apiGroups": [
                "extensions",
                "networking.k8s.io"
            ],
            "resources": [
                "ingresses/status",
                "ingresses"
            ],
            "verbs": [
                "get",
                "list",
                "watch"
            ]
        },
        {
            "effect": "allow",
            "apiGroups": [
                "metrics.eks.amazonaws.com"
            ],
            "resources": [
                "kcm/metrics",
                "ksh/metrics"
            ],
            "verbs": [
                "get"
            ]
        },
        {
            "effect": "allow",
            "nonResourceURLs": [
                "/metrics"
            ],
            "verbs": [
                "get"
            ]
        }
    ]
}
```

### 手動設定 Amazon EKS 以進行抓取器存取
<a name="AMP-collector-eks-manual-setup"></a>

如果您偏好使用 `aws-auth ConfigMap`來控制對 kubernetes 叢集的存取，您仍然可以讓 Amazon Managed Service for Prometheus 湊集器存取您的指標。下列步驟將授予 Amazon Managed Service for Prometheus 從您的 Amazon EKS 叢集抓取指標的存取權。

**注意**  
如需 `ConfigMap`和 存取項目的詳細資訊，請參閱《*Amazon EKS 使用者指南*》中的[允許 IAM 角色或使用者存取 Kubernetes](https://docs.aws.amazon.com/eks/latest/userguide/access-entries.html)。

此程序使用 `kubectl`和 AWS CLI。如需有關安裝 `kubectl` 的資訊，請參閱《Amazon EKS 使用者指南》**中的[安裝 kubectl](https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html)。

**手動設定 Amazon EKS 叢集以進行受管指標抓取**

1. 使用下列內文建立名為 `clusterrole-binding.yml` 的檔案：

   ```
   apiVersion: rbac.authorization.k8s.io/v1
   kind: ClusterRole
   metadata:
     name: aps-collector-role
   rules:
     - apiGroups: [""]
       resources: ["nodes", "nodes/proxy", "nodes/metrics", "services", "endpoints", "pods", "ingresses", "configmaps"]
       verbs: ["describe", "get", "list", "watch"]
     - apiGroups: ["extensions", "networking.k8s.io"]
       resources: ["ingresses/status", "ingresses"]
       verbs: ["describe", "get", "list", "watch"]
     - nonResourceURLs: ["/metrics"]
       verbs: ["get"]
     - apiGroups: ["metrics.eks.amazonaws.com"]
       resources: ["kcm/metrics", "ksh/metrics"]
       verbs: ["get"]
   ---
   apiVersion: rbac.authorization.k8s.io/v1
   kind: ClusterRoleBinding
   metadata:
     name: aps-collector-user-role-binding
   subjects:
   - kind: User
     name: aps-collector-user
     apiGroup: rbac.authorization.k8s.io
   roleRef:
     kind: ClusterRole
     name: aps-collector-role
     apiGroup: rbac.authorization.k8s.io
   ```

1. 在叢集中執行下列命令：

   ```
   kubectl apply -f clusterrole-binding.yml
   ```

   這將建立叢集角色連結和規則。此範例使用 `aps-collector-role` 作為角色名稱和 `aps-collector-user` 作為使用者名稱。

1. 以下命令為您提供有關含有 ID 為 *scraper-id* 的資訊。這是您使用上一節命令建立的湊集器。

   ```
   aws amp describe-scraper --scraper-id scraper-id
   ```

1. 在 `describe-scraper` 的結果中尋找 `roleArn`，其格式如下：

   ```
   arn:aws:iam::account-id:role/aws-service-role/scraper.aps.amazonaws.com/AWSServiceRoleForAmazonPrometheusScraper_unique-id
   ```

   Amazon EKS 需要此 ARN 的不同格式。您必須調整傳回 ARN 的格式，以便在下一步中使用。編輯以比對此格式：

   ```
   arn:aws:iam::account-id:role/AWSServiceRoleForAmazonPrometheusScraper_unique-id
   ```

   例如，此 ARN：

   ```
   arn:aws:iam::111122223333:role/aws-service-role/scraper.aps.amazonaws.com/AWSServiceRoleForAmazonPrometheusScraper_1234abcd-56ef-7
   ```

   必須改寫為：

   ```
   arn:aws:iam::111122223333:role/AWSServiceRoleForAmazonPrometheusScraper_1234abcd-56ef-7
   ```

1. 使用上一個步驟中修改後的 `roleArn` 以及您的叢集名稱和區域，在叢集中執行下列命令：

   ```
   eksctl create iamidentitymapping --cluster cluster-name --region region-id --arn roleArn --username aps-collector-user
   ```

   這允許湊集器使用 `clusterrole-binding.yml` 檔案中建立的角色和使用者存取叢集。

## 尋找並刪除湊集器
<a name="AMP-collector-list-delete"></a>

您可以使用 AWS API 或 AWS CLI 列出您帳戶中的抓取器或刪除它們。

**注意**  
請確定您使用的是最新版本的 AWS CLI 或 SDK。最新版本為您提供最新的功能和功能，以及安全性更新。或者，使用 [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html)，它會自動提供up-to-date命令列體驗。

若要列出您帳戶中的所有抓取器，請使用 [ListScrapers](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_ListScrapers.html) API 操作。

或者，使用 AWS CLI呼叫：

```
aws amp list-scrapers --region aws-region
```

`ListScrapers` 會傳回您帳戶中的所有湊集器，例如：

```
{
    "scrapers": [
        {
            "scraperId": "s-1234abcd-56ef-7890-abcd-1234ef567890",
            "arn": "arn:aws:aps:us-west-2:123456789012:scraper/s-1234abcd-56ef-7890-abcd-1234ef567890",
            "roleArn": "arn:aws:iam::123456789012:role/aws-service-role/AWSServiceRoleForAmazonPrometheusScraper_1234abcd-2931",
            "status": {
                "statusCode": "DELETING"
            },
            "createdAt": "2023-10-12T15:22:19.014000-07:00",
            "lastModifiedAt": "2023-10-12T15:55:43.487000-07:00",
            "tags": {},
            "source": {
                "eksConfiguration": {
                    "clusterArn": "arn:aws:eks:us-west-2:123456789012:cluster/my-cluster",
                    "securityGroupIds": [
                        "sg-1234abcd5678ef90"
                    ],
                    "subnetIds": [
                        "subnet-abcd1234ef567890", 
                        "subnet-1234abcd5678ab90"
                    ]
                }
            },
            "destination": {
                "ampConfiguration": {
                    "workspaceArn": "arn:aws:aps:us-west-2:123456789012:workspace/ws-1234abcd-5678-ef90-ab12-cdef3456a78"
                }
            }
        }
    ]
}
```

若要刪除抓取器，請使用 `ListScrapers`操作尋找您要刪除之抓取器`scraperId`的 ，然後使用 [DeleteScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DeleteScraper.html) 操作將其刪除。

或者，使用 AWS CLI呼叫：

```
aws amp delete-scraper --scraper-id scraperId
```

## 湊集器組態
<a name="AMP-collector-configuration"></a>

您可以使用與 Prometheus 相容的湊集器組態控制湊集器如何探索和收集指標。例如，您可以變更將指標傳送至工作區的間隔。您也可以使用重新標籤來動態重新寫入指標的標籤。湊集器組態是一個 YAML 檔案，屬於湊集器定義的一部份。

建立新的湊集器時，您可以透過在 API 呼叫中提供 base64 編碼的 YAML 檔案來指定組態。您可以透過 Amazon Managed Service for Prometheus API 中的 `GetDefaultScraperConfiguration` 作業下載一般用途組態檔案。

若要修改抓取器的組態，您可以使用 `UpdateScraper`操作。如果您需要更新指標的來源 （例如，其他 Amazon EKS 叢集），您必須刪除抓取器，並使用新來源重新建立該抓取器。

**支援的組態**

如需抓取器組態格式的相關資訊，包括可能值的詳細明細，請參閱 Prometheus 文件中的[組態](https://prometheus.io/docs/prometheus/latest/configuration/configuration/)。全域組態選項和 `<scrape_config>` 選項說明最常需要的選項。

由於 Amazon EKS 是唯一支援的服務，因此支援的唯一服務探索組態 (`<*_sd_config>`) 是 `<kubernetes_sd_config>`。

允許組態區段的完整清單：
+ `<global>`
+ `<scrape_config>`
+ `<static_config>`
+ `<relabel_config>`
+ `<metric_relabel_configs>`
+ `<kubernetes_sd_config>`

這些區段中的限制會列在範例組態檔案之後。

**範例組態檔案**

以下是具有 30 秒湊集間隔的範例 YAML 組態檔。此範例包含對 kube API 伺服器指標，以及 kube-controller-manager 和 kube-scheduler 指標的支援。如需詳細資訊，請參閱《*Amazon EKS 使用者指南*》中的[擷取 Prometheus 格式的控制平面原始指標](https://docs.aws.amazon.com/eks/latest/userguide/view-raw-metrics.html#scheduler-controller-metrics)。

```
global:
   scrape_interval: 30s
   external_labels:
     clusterArn: apiserver-test-2
scrape_configs:
  - job_name: pod_exporter
    kubernetes_sd_configs:
      - role: pod
  - job_name: cadvisor
    scheme: https
    authorization:
      type: Bearer
      credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
    kubernetes_sd_configs:
      - role: node
    relabel_configs:
      - action: labelmap
        regex: __meta_kubernetes_node_label_(.+)
      - replacement: kubernetes.default.svc:443
        target_label: __address__
      - source_labels: [__meta_kubernetes_node_name]
        regex: (.+)
        target_label: __metrics_path__
        replacement: /api/v1/nodes/$1/proxy/metrics/cadvisor
  # apiserver metrics
  - scheme: https
    authorization:
      type: Bearer
      credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
    job_name: kubernetes-apiservers
    kubernetes_sd_configs:
    - role: endpoints
    relabel_configs:
    - action: keep
      regex: default;kubernetes;https
      source_labels:
      - __meta_kubernetes_namespace
      - __meta_kubernetes_service_name
      - __meta_kubernetes_endpoint_port_name
  # kube proxy metrics
  - job_name: kube-proxy
    honor_labels: true
    kubernetes_sd_configs:
    - role: pod
    relabel_configs:
    - action: keep
      source_labels:
      - __meta_kubernetes_namespace
      - __meta_kubernetes_pod_name
      separator: '/'
      regex: 'kube-system/kube-proxy.+'
    - source_labels:
      - __address__
      action: replace
      target_label: __address__
      regex: (.+?)(\\:\\d+)?
      replacement: $1:10249
  # Scheduler metrics
  - job_name: 'ksh-metrics'
    kubernetes_sd_configs:
    - role: endpoints
    metrics_path: /apis/metrics.eks.amazonaws.com/v1/ksh/container/metrics
    scheme: https
    bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
    relabel_configs:
    - source_labels:
      - __meta_kubernetes_namespace
      - __meta_kubernetes_service_name
      - __meta_kubernetes_endpoint_port_name
      action: keep
      regex: default;kubernetes;https
  # Controller Manager metrics
  - job_name: 'kcm-metrics'
    kubernetes_sd_configs:
    - role: endpoints
    metrics_path: /apis/metrics.eks.amazonaws.com/v1/kcm/container/metrics
    scheme: https
    bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
    relabel_configs:
    - source_labels:
      - __meta_kubernetes_namespace
      - __meta_kubernetes_service_name
      - __meta_kubernetes_endpoint_port_name
      action: keep
      regex: default;kubernetes;https
```

以下是 AWS 受管收集器特有的限制：
+ **湊集間隔**：湊集器組態無法指定少於 30 秒的湊集間隔。
+ **目標**：`static_config` 中的目標必須指定為 IP 地址。
+ **DNS 解析** – 與目標名稱相關，此組態中辨識的唯一伺服器名稱是 Kubernetes api 伺服器 `kubernetes.default.svc`。所有其他機器名稱都必須由 IP 地址指定。
+ **授權** – 如果不需要授權，請省略 。如果需要，授權必須是 `Bearer`，而且必須指向檔案 `/var/run/secrets/kubernetes.io/serviceaccount/token`。換句話說，如果使用 ，授權區段必須如下所示：

  ```
      authorization:
        type: Bearer
        credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ```
**注意**  
`type: Bearer` 是預設值，因此可以省略。

## 對湊集器組態進行移難排解
<a name="AMP-collector-troubleshoot"></a>

Amazon Managed Service for Prometheus 收集器會自動探索和湊集指標。但是，若未在 Amazon Managed Service for Prometheus 工作區中看到您希望看到的指標，該如何進行疑難排解？

**重要**  
確認已啟用 Amazon EKS 叢集的私有存取。如需詳細資訊，請參閱《*Amazon EKS 使用者指南*》中的[叢集私有端點](https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html#cluster-endpoint-private)。

`up` 指標是一個有助益的工具。針對 Amazon Managed Service for Prometheus 收集器探索的每個端點，皆會自動分配此指標。此指標有三種狀態，可協助您疑難排解收集器內所發生的事情。
+ `up` 不存在 - 若端點沒有 `up` 指標，則這表示收集器找不到端點。

  如果您確定端點存在，收集器可能無法找到它有幾個原因。
  + 您可能需要調整湊集組態。探索`relabel_config`可能需要調整。
  + `role` 用於探索的 可能有問題。
  + Amazon EKS 叢集使用的 Amazon VPC 可能尚未[啟用 DNS](https://docs.aws.amazon.com/vpc/latest/userguide/AmazonDNS-concepts.html)，這會使收集器無法尋找端點。
+ `up` 已存在，但始終為 0 — 如果 `up` 已存在但為 0，則收集器能夠探索端點，但找不到任何與 Prometheus 相容的指標。

  在這種情況下，您可以嘗試直接對端點使用 `curl` 命令。您可以驗證詳細資訊是否正確，例如，您正在使用的通訊協定 (`http` 或 `https`)、端點或連接埠。您也可以檢查端點是否以有效的`200`回應回應，並遵循 Prometheus 格式。最後，回應的內文不能大於允許的大小上限。（如需 AWS 受管收集器的限制，請參閱下一節。)
+ `up` 已存在且大於 0 — 若 `up` 已存在且大於 0，則指標會傳送至 Amazon Managed Service for Prometheus。

  驗證您正在尋找 Amazon Managed Service for Prometheus (或您的替代儀表板，例如 Amazon Managed Grafana) 中的正確指標。您可以再次使用 curl 來檢查`/metrics`端點中的預期數據。同時檢查您是否未超過其他限制，例如每個湊集器的端點數量。您可以使用 檢查指標計數，以檢查要抓取的`up`指標端點數量`count(up)`。

## 湊集器限制
<a name="AMP-collector-limits"></a>

Amazon Managed Service for Prometheus 所提供全受管湊集器的限制較少。
+ **區域**：您的 EKS 叢集、受管理湊集器和 Amazon Managed Service for Prometheus workspace 必須位於相同 AWS 區域。
+ **收集器**：各帳戶最多可以為每個區域提供 10 個 Amazon Managed Service for Prometheus 湊集器。
**注意**  
您可以透過[請求增加配額](https://console.aws.amazon.com/support/home#/case/create?issueType=service-limit-increase)來請求增加此限制。
+ **指標回應**：來自任何一個 `/metrics` 端點請求的回應主體不能超過 50 MB。
+ **每個湊集器的端點**：湊集器最多可以湊集 30,000 `/metrics` 個端點。
+ **湊集間隔**：湊集器組態無法指定少於 30 秒的湊集間隔。

# 設定 Amazon MSK 的受管 Prometheus 收集器
<a name="prom-msk-integration"></a>

若要使用 Amazon Managed Service for Prometheus 收集器，您可以建立抓取器，在 Amazon Managed Streaming for Apache Kafka 叢集中探索和提取指標。您也可以建立與 Amazon Elastic Kubernetes Service 整合的抓取器。如需詳細資訊，請參閱[整合 Amazon EKS](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html)。

## 建立湊集器
<a name="prom-msk-create-scraper"></a>

Amazon Managed Service for Prometheus 收集器包含一個抓取器，可從 Amazon MSK 叢集探索和收集指標。Amazon Managed Service for Prometheus 可為您管理湊集器，提供所需的可擴展性、安全性和可靠性，而無需自行管理任何執行個體、代理程式或湊集器。

您可以使用 AWS API 或 建立抓取器 AWS CLI ，如下列程序所述。

您需先滿足幾項先決條件，才能建立自己的湊集器：
+ 您必須建立 Amazon MSK 叢集。
+ 設定 Amazon MSK 叢集的安全群組，以允許 Amazon VPC 內連接埠 **11001 (JMX Exporter)** 和 **11002 (Node Exporter)** 的傳入流量，因為抓取器需要存取這些 DNS 記錄才能收集 Prometheus 指標。
+ Amazon MSK 叢集所在的 Amazon VPC 必須[啟用 DNS](https://docs.aws.amazon.com/vpc/latest/userguide/AmazonDNS-concepts.html)。

**注意**  
叢集會依其 Amazon 資源名稱 (ARN) 與抓取器建立關聯。如果您刪除叢集，然後使用相同名稱建立新的叢集，則 ARN 將重複使用於新叢集。因此，抓取器會嘗試收集新叢集的指標。[您可以將抓取器](#prom-msk-delete-scraper)與刪除叢集分開刪除。

------
#### [ To create a scraper using the AWS API ]

使用 `CreateScraper` API 操作來建立具有 AWS API 的抓取器。下列範例在美國東部 （維吉尼亞北部） 區域建立抓取器。將*範例*內容取代為您的 Amazon MSK 叢集資訊，並提供您的抓取器組態。

**注意**  
設定安全群組和子網路以符合您的目標叢集。在兩個可用區域中包含至少兩個子網路。

```
                POST /scrapers HTTP/1.1
Content-Length: 415 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: aws-cli/1.18.147 Python/2.7.18 Linux/5.4.58-37.125.amzn2int.x86_64 botocore/1.18.6

{
    "alias": "myScraper",
    "destination":  {
        "ampConfiguration": {
            "workspaceArn": "arn:aws:aps:us-east-1:123456789012:workspace/ws-workspace-id"
        }
    },
    "source": {
        "vpcConfiguration": {
            "securityGroupIds": ["sg-security-group-id"],
            "subnetIds": ["subnet-subnet-id-1", "subnet-subnet-id-2"]
        }
    },
    "scrapeConfiguration": {
        "configurationBlob": base64-encoded-blob
    }
}
```

在此範例中， `scrapeConfiguration` 參數需要 base64 編碼的 Prometheus 組態 YAML 檔案，指定 MSK 叢集的 DNS 記錄。

每個 DNS 記錄代表特定可用區域中的中介裝置端點，可讓用戶端連線到分散在所選AZs中介裝置，以獲得高可用性。

MSK 叢集屬性中的 DNS 記錄數目對應至叢集組態中的代理程式節點和可用區域數目：
+ **預設組態** – 3 個 AZs的 3 個代理節點 = 3 個 DNS 記錄
+ **自訂組態** – 2 個 AZs的 2 個代理節點 = 2 個 DNS 記錄

若要取得 MSK 叢集的 DNS 記錄，請開啟 MSK 主控台，網址為 https：//[https://console.aws.amazon.com/msk/home?region=us-east-1\$1/home/](https://console.aws.amazon.com/msk/home?region=us-east-1#/home/)。前往 MSK 叢集。選擇**屬性**、**中介裝置**和**端點**。

您有兩個設定 Prometheus 以從 MSK 叢集抓取指標的選項：

1. **叢集層級 DNS 解析 （建議）** – 使用叢集的基本 DNS 名稱自動探索所有代理程式。如果您的中介裝置端點是 `b-1.clusterName.xxx.xxx.xxx`，請使用 `clusterName.xxx.xxx.xxx`做為 DNS 記錄。這可讓 Prometheus 自動抓取叢集中的所有代理程式。

   **個別代理程式端點** – 個別指定每個代理程式端點以進行精細控制。在組態中使用完整的代理程式識別符 (b-1、b-2)。例如：

   ```
   dns_sd_configs:
     - names:
       - b-1.clusterName.xxx.xxx.xxx
       - b-2.clusterName.xxx.xxx.xxx  
       - b-3.clusterName.xxx.xxx.xxx
   ```

**注意**  
從 AWS 主控台將 取代`clusterName.xxx.xxx.xxx`為您實際的 MSK 叢集端點。

如需詳細資訊，請參閱 *Prometheus* 文件中的 [<dns\$1sd\$1config>](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dns_sd_config)。

以下是抓取器組態檔案的範例：

```
global:
  scrape_interval: 30s
  external_labels:
    clusterArn: msk-test-1

scrape_configs:
  - job_name: msk-jmx
    scheme: http
    metrics_path: /metrics
    scrape_timeout: 10s
    dns_sd_configs:
      - names:
          - dns-record-1
          - dns-record-2
          - dns-record-3
        type: A
        port: 11001
    relabel_configs:
      - source_labels: [__meta_dns_name]
        target_label: broker_dns
      - source_labels: [__address__]
        target_label: instance
        regex: '(.*)'
        replacement: '${1}'

  - job_name: msk-node
    scheme: http
    metrics_path: /metrics
    scrape_timeout: 10s
    dns_sd_configs:
      - names:
          - dns-record-1
          - dns-record-2
          - dns-record-3
        type: A
        port: 11002
    relabel_configs:
      - source_labels: [__meta_dns_name]
        target_label: broker_dns
      - source_labels: [__address__]
        target_label: instance
        regex: '(.*)'
        replacement: '${1}'
```

執行下列其中一個命令，將 YAML 檔案轉換為 base64。您也可以使用任何線上 base64 轉換器來轉換檔案。

**Example Linux/macOS**  

```
echo -n scraper config updated with dns records | base64 
```

**Example Windows PowerShell**  

```
[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(scraper config updated with dns records))
```

------
#### [ To create a scraper using the AWS CLI ]

使用 `create-scraper`命令來使用 建立抓取器 AWS Command Line Interface。下列範例在美國東部 （維吉尼亞北部） 區域建立抓取器。將*範例*內容取代為您的 Amazon MSK 叢集資訊，並提供您的抓取器組態。

**注意**  
設定安全群組和子網路以符合您的目標叢集。在兩個可用區域中包含至少兩個子網路。

```
aws amp create-scraper \
 --source vpcConfiguration="{securityGroupIds=['sg-security-group-id'],subnetIds=['subnet-subnet-id-1', 'subnet-subnet-id-2']}" \ 
--scrape-configuration configurationBlob=base64-encoded-blob \
 --destination ampConfiguration="{workspaceArn='arn:aws:aps:us-west-2:123456789012:workspace/ws-workspace-id'}"
```

------
+ 以下是您可以搭配 AWS API 使用的湊集器操作完整清單：

  使用 [CreateScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_CreateScraper.html) API 操作建立抓取器。
+ 使用 [ListScrapers](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_ListScrapers.html) API 操作列出現有的抓取器。
+ 使用 [UpdateScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_UpdateScraper.html) API 操作更新抓取器的別名、組態或目的地。
+ 使用 [DeleteScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DeleteScraper.html) API 操作刪除抓取器。
+ 使用 [DescribeScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DescribeScraper.html) API 操作取得有關抓取器的詳細資訊。

## 跨帳戶設定
<a name="prom-msk-cross-account"></a>

若要在您要收集指標的 Amazon MSK 叢集位於與 Amazon Managed Service for Prometheus 收集器不同的帳戶中時，在跨帳戶設定中建立抓取器，請使用下列程序。

例如，當您有兩個帳戶時，Amazon MSK `account_id_source` 所在的第一個來源帳戶，以及 `account_id_target` Amazon Managed Service for Prometheus 工作區所在的第二個目標帳戶。

**在跨帳戶設定中建立抓取器**

1. 在來源帳戶中，建立角色`arn:aws:iam::111122223333:role/Source`並新增下列信任政策。

   ```
   {
       "Effect": "Allow",
       "Principal": {
       "Service": [
           "scraper.aps.amazonaws.com"
        ]
       },
       "Action": "sts:AssumeRole",
       "Condition": {
           "ArnEquals": {
               "aws:SourceArn": "arn:aws:aps:aws-region:111122223333:scraper/scraper-id"
           },
           "StringEquals": {
               "AWS:SourceAccount": "111122223333"
           }
       }
   }
   ```

1. 在來源 (Amazon MSK 叢集） 和目標 (Amazon Managed Service for Prometheus 工作區） 的每個組合上，您需要建立角色，`arn:aws:iam::444455556666:role/Target`並新增具有 [AmazonPrometheusRemoteWriteAccess](https://docs.aws.amazon.com/prometheus/latest/userguide/security-iam-awsmanpol.html) 許可的下列信任政策。

   ```
   {
     "Effect": "Allow",
     "Principal": {
        "AWS": "arn:aws:iam::111122223333:role/Source"
     },
     "Action": "sts:AssumeRole",
     "Condition": {
        "StringEquals": {
           "sts:ExternalId": "arn:aws:aps:aws-region:111122223333:scraper/scraper-id"
         }
     }
   }
   ```

1. 使用 `--role-configuration`選項建立抓取器。

   ```
   aws amp create-scraper \ --source vpcConfiguration="{subnetIds=[subnet-subnet-id], "securityGroupIds": ["sg-security-group-id"]}" \ --scrape-configuration configurationBlob=<base64-encoded-blob> \ --destination ampConfiguration="{workspaceArn='arn:aws:aps:aws-region:444455556666:workspace/ws-workspace-id'}"\ --role-configuration '{"sourceRoleArn":"arn:aws:iam::111122223333:role/Source", "targetRoleArn":"arn:aws:iam::444455556666:role/Target"}'
   ```

1. 驗證抓取器建立。

   ```
   aws amp list-scrapers
   {
       "scrapers": [
           {
               "scraperId": "s-example123456789abcdef0",
               "arn": "arn:aws:aps:aws-region:111122223333:scraper/s-example123456789abcdef0": "arn:aws:iam::111122223333:role/Source",
               "status": "ACTIVE",
               "creationTime": "2025-10-27T18:45:00.000Z",
               "lastModificationTime": "2025-10-27T18:50:00.000Z",
               "tags": {},
               "statusReason": "Scraper is running successfully",
               "source": {
                   "vpcConfiguration": {
                       "subnetIds": ["subnet-subnet-id"],
                       "securityGroupIds": ["sg-security-group-id"]
                   }
               },
               "destination": {
                   "ampConfiguration": {
                       "workspaceArn": "arn:aws:aps:aws-region:444455556666:workspace/ws-workspace-id'"
                   }
               },
               "scrapeConfiguration": {
                   "configurationBlob": "<base64-encoded-blob>"
               }
           }
       ]
   }
   ```

## 在 RoleConfiguration 和服務連結角色之間變更
<a name="prom-msk-changing-roles"></a>

當您想要切換回服務連結角色，而不是 `RoleConfiguration`寫入 Amazon Managed Service for Prometheus 工作區時，您必須更新 ，`UpdateScraper`並在與抓取器相同的帳戶中提供工作區，而不需要 `RoleConfiguration`。`RoleConfiguration` 會從抓取器中移除 ，並使用服務連結角色。

當您變更與抓取器相同帳戶中的工作區，並且想要繼續使用 時`RoleConfiguration`，您必須再次`RoleConfiguration`在 上提供 `UpdateScraper`。

## 尋找並刪除湊集器
<a name="prom-msk-delete-scraper"></a>

您可以使用 AWS API 或 AWS CLI 列出您帳戶中的抓取器或刪除它們。

**注意**  
請確定您使用的是最新版本的 AWS CLI 或 SDK。最新版本提供最新的功能和功能，以及安全性更新。或者，使用 [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html)，它會自動提供up-to-date命令列體驗。

若要列出您帳戶中的所有抓取器，請使用 [ListScrapers](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_ListScrapers.html) API 操作。

或者，使用 AWS CLI呼叫：

```
aws amp list-scrapers
```

`ListScrapers` 會傳回您帳戶中的所有湊集器，例如：

```
{
    "scrapers": [
        {
            "scraperId": "s-1234abcd-56ef-7890-abcd-1234ef567890",
            "arn": "arn:aws:aps:aws-region:123456789012:scraper/s-1234abcd-56ef-7890-abcd-1234ef567890",
            "roleArn": "arn:aws:iam::123456789012:role/aws-service-role/AWSServiceRoleForAmazonPrometheusScraper_1234abcd-2931",
            "status": {
                "statusCode": "DELETING"
            },
            "createdAt": "2023-10-12T15:22:19.014000-07:00",
            "lastModifiedAt": "2023-10-12T15:55:43.487000-07:00",
            "tags": {},
            "source": {
                "vpcConfiguration": {
                   "securityGroupIds": [
                        "sg-1234abcd5678ef90"
                    ],
                    "subnetIds": [
                        "subnet-abcd1234ef567890", 
                        "subnet-1234abcd5678ab90"
                    ]
                }
            },
            "destination": {
                "ampConfiguration": {
                    "workspaceArn": "arn:aws:aps:aws-region:123456789012:workspace/ws-1234abcd-5678-ef90-ab12-cdef3456a78"
                }
            }
        }
    ]
}
```

若要刪除抓取器，請使用 `ListScrapers`操作尋找您要刪除之抓取器`scraperId`的 ，然後使用 [DeleteScraper](https://docs.aws.amazon.com/prometheus/latest/APIReference/API_DeleteScraper.html) 操作將其刪除。

或者，使用 AWS CLI呼叫：

```
aws amp delete-scraper --scraper-id scraperId
```

## 從 Amazon MSK 收集的指標
<a name="prom-msk-metrics"></a>

當您與 Amazon MSK 整合時，Amazon Managed Service for Prometheus 收集器會自動抓取下列指標：

### 指標：jmx\$1exporter 和 pod\$1exporter 任務
<a name="broker-metrics"></a>


| 指標 | 描述/目的 | 
| --- | --- | 
|  jmx\$1config\$1reload\$1failure\$1total  |  JMX 匯出工具無法重新載入其組態檔案的總次數。  | 
|  jmx\$1scrape\$1duration\$1seconds  |  目前收集週期的抓取 JMX 指標所花費的時間，以秒為單位。  | 
|  jmx\$1scrape\$1error  |  指出在 JMX 指標抓取期間是否發生錯誤 (1 = 錯誤，0 = 成功）。  | 
|  java\$1lang\$1Memory\$1HeapMemoryUsage\$1used  |  JVM 目前使用的堆積記憶體數量 （以位元組為單位）。  | 
|  java\$1lang\$1Memory\$1HeapMemoryUsage\$1max  |  可用於記憶體管理的堆積記憶體數量上限 （以位元組為單位）。  | 
|  java\$1lang\$1Memory\$1NonHeapMemoryUsage\$1used  |  JVM 目前使用的非堆積記憶體數量 （以位元組為單位）。  | 
|  kafka\$1cluster\$1Partition\$1Value  |  與 Kafka 叢集分割區相關的目前狀態或值，依分割區 ID 和主題細分。  | 
|  kafka\$1consumer\$1consumer\$1coordinator\$1metrics\$1assigned\$1partitions  |  目前指派給此取用者的分割區數量。  | 
|  kafka\$1consumer\$1consumer\$1coordinator\$1metrics\$1commit\$1latency\$1avg  |  遞交偏移所需的平均時間，以毫秒為單位。  | 
|  kafka\$1consumer\$1consumer\$1coordinator\$1metrics\$1commit\$1rate  |  每秒偏移遞交的數量。  | 
|  kafka\$1consumer\$1consumer\$1coordinator\$1metrics\$1failed\$1rebalance\$1total  |  失敗的取用者群組重新平衡總數。  | 
|  kafka\$1consumer\$1consumer\$1coordinator\$1metrics\$1last\$1heartbeat\$1seconds\$1ago  |  自上次將活動訊號傳送至協調器以來的秒數。  | 
|  kafka\$1consumer\$1consumer\$1coordinator\$1metrics\$1rebalance\$1latency\$1avg  |  取用者群組重新平衡的平均時間，以毫秒為單位。  | 
|  kafka\$1consumer\$1consumer\$1coordinator\$1metrics\$1rebalance\$1total  |  取用者群組重新平衡的總數。  | 
|  kafka\$1consumer\$1consumer\$1fetch\$1manager\$1metrics\$1bytes\$1consumed\$1rate  |  消費者每秒耗用的平均位元組數。  | 
|  kafka\$1consumer\$1consumer\$1fetch\$1manager\$1metrics\$1fetch\$1latency\$1avg  |  擷取請求所需的平均時間，以毫秒為單位。  | 
|  kafka\$1consumer\$1consumer\$1fetch\$1manager\$1metrics\$1fetch\$1rate  |  每秒擷取請求的數量。  | 
|  kafka\$1consumer\$1consumer\$1fetch\$1manager\$1metrics\$1records\$1consumed\$1rate  |  每秒耗用的平均記錄數。  | 
|  kafka\$1consumer\$1consumer\$1fetch\$1manager\$1metrics\$1records\$1lag\$1max  |  此取用者中任何分割區的記錄數量的最大延遲。  | 
|  kafka\$1consumer\$1consumer\$1metrics\$1connection\$1count  |  目前作用中連線的數量。  | 
|  kafka\$1consumer\$1consumer\$1metrics\$1incoming\$1byte\$1rate  |  每秒從所有伺服器接收的平均位元組數。  | 
|  kafka\$1consumer\$1consumer\$1metrics\$1last\$1poll\$1seconds\$1ago  |  自上次消費者輪詢 () 呼叫以來的秒數。  | 
|  kafka\$1consumer\$1consumer\$1metrics\$1request\$1rate  |  每秒傳送的請求數。  | 
|  kafka\$1consumer\$1consumer\$1metrics\$1response\$1rate  |  每秒收到的回應數。  | 
|  kafka\$1consumer\$1group\$1ConsumerLagMetrics\$1Value  |  取用者群組的目前取用者延遲值，指出取用者落後多遠。  | 
|  kafka\$1controller\$1KafkaController\$1Value  |  Kafka 控制器的目前狀態或值 (1 = 作用中控制器，0 = 非作用中）。  | 
|  kafka\$1controller\$1ControllerEventManager\$1Count  |  處理的控制器事件總數。  | 
|  kafka\$1controller\$1ControllerEventManager\$1Mean  |  處理控制器事件所需的平均 （平均） 時間。  | 
|  kafka\$1controller\$1ControllerStats\$1MeanRate  |  每秒控制器統計資料操作的平均速率。  | 
|  kafka\$1coordinator\$1group\$1GroupMetadataManager\$1Value  |  取用者群組之群組中繼資料管理員的目前狀態或值。  | 
|  kafka\$1log\$1LogFlushStats\$1Count  |  日誌排清操作的總數。  | 
|  kafka\$1log\$1LogFlushStats\$1Mean  |  日誌排清操作的平均 （平均） 時間。  | 
|  kafka\$1log\$1LogFlushStats\$1MeanRate  |  每秒日誌排清操作的平均速率。  | 
|  kafka\$1network\$1RequestMetrics\$1Count  |  已處理的網路請求總數。  | 
|  kafka\$1network\$1RequestMetrics\$1Mean  |  處理網路請求所需的平均 （平均） 時間。  | 
|  kafka\$1network\$1RequestMetrics\$1MeanRate  |  每秒網路請求的平均速率。  | 
|  kafka\$1network\$1Acceptor\$1MeanRate  |  每秒可接受連線的平均速率。  | 
|  kafka\$1server\$1Fetch\$1queue\$1size  |  擷取請求佇列的目前大小。  | 
|  kafka\$1server\$1Produce\$1queue\$1size  |  生產請求佇列的目前大小。  | 
|  kafka\$1server\$1Request\$1queue\$1size  |  一般請求佇列的目前大小。  | 
|  kafka\$1server\$1BrokerTopicMetrics\$1Count  |  中介裝置主題操作的總數 （訊息輸入/輸出、位元組輸入/輸出）。  | 
|  kafka\$1server\$1BrokerTopicMetrics\$1MeanRate  |  每秒中介裝置主題操作的平均速率。  | 
|  kafka\$1server\$1BrokerTopicMetrics\$1OneMinuteRate  |  中介裝置主題操作的一分鐘移動平均速率。  | 
|  kafka\$1server\$1DelayedOperationPurgatory\$1Value  |  查詢中的目前延遲操作數量 （等待完成）。  | 
|  kafka\$1server\$1DelayedFetchMetrics\$1MeanRate  |  每秒延遲擷取操作的平均速率。  | 
|  kafka\$1server\$1FetcherLagMetrics\$1Value  |  複本擷取器執行緒的目前延遲值 （落後領導者多遠）。  | 
|  kafka\$1server\$1FetcherStats\$1MeanRate  |  每秒擷取器操作的平均速率。  | 
|  kafka\$1server\$1ReplicaManager\$1Value  |  複本管理員的目前狀態或值。  | 
|  kafka\$1server\$1ReplicaManager\$1MeanRate  |  每秒複本管理員操作的平均速率。  | 
|  kafka\$1server\$1LeaderReplication\$1byte\$1rate  |  對於此代理程式為領導者的分割區，每秒複寫的位元組速率。  | 
|  kafka\$1server\$1group\$1coordinator\$1metrics\$1group\$1completed\$1rebalance\$1count  |  已完成取用者群組重新平衡的總數。  | 
|  kafka\$1server\$1group\$1coordinator\$1metrics\$1offset\$1commit\$1count  |  偏移遞交操作的總數。  | 
|  kafka\$1server\$1group\$1coordinator\$1metrics\$1offset\$1commit\$1rate  |  每秒偏移遞交操作的速率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1connection\$1count  |  目前作用中連線的數量。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1connection\$1creation\$1rate  |  每秒建立新連線的速率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1connection\$1close\$1rate  |  每秒連線關閉速率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1failed\$1authentication\$1total  |  失敗的身分驗證嘗試總數。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1incoming\$1byte\$1rate  |  每秒傳入位元組的速率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1outgoing\$1byte\$1rate  |  每秒傳出位元組的速率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1request\$1rate  |  每秒請求率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1response\$1rate  |  每秒回應速率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1network\$1io\$1rate  |  每秒的網路 I/O 操作速率。  | 
|  kafka\$1server\$1socket\$1server\$1metrics\$1io\$1ratio  |  在 I/O 操作中花費的時間部分。  | 
|  kafka\$1server\$1controller\$1channel\$1metrics\$1connection\$1count  |  控制器通道的目前作用中連線數。  | 
|  kafka\$1server\$1controller\$1channel\$1metrics\$1incoming\$1byte\$1rate  |  控制器通道每秒傳入位元組的速率。  | 
|  kafka\$1server\$1controller\$1channel\$1metrics\$1outgoing\$1byte\$1rate  |  控制器通道每秒傳出位元組的速率。  | 
|  kafka\$1server\$1controller\$1channel\$1metrics\$1request\$1rate  |  控制器通道每秒請求的速率。  | 
|  kafka\$1server\$1replica\$1fetcher\$1metrics\$1connection\$1count  |  複本擷取器的目前作用中連線數。  | 
|  kafka\$1server\$1replica\$1fetcher\$1metrics\$1incoming\$1byte\$1rate  |  複本擷取器每秒傳入位元組的速率。  | 
|  kafka\$1server\$1replica\$1fetcher\$1metrics\$1request\$1rate  |  複本擷取器的每秒請求率。  | 
|  kafka\$1server\$1replica\$1fetcher\$1metrics\$1failed\$1authentication\$1total  |  複本擷取器的失敗身分驗證嘗試總數。  | 
|  kafka\$1server\$1ZooKeeperClientMetrics\$1Count  |  ZooKeeper 用戶端操作的總計數。  | 
|  kafka\$1server\$1ZooKeeperClientMetrics\$1Mean  |  ZooKeeper 用戶端操作的平均延遲。  | 
|  kafka\$1server\$1KafkaServer\$1Value  |  Kafka 伺服器的目前狀態或值 （通常表示伺服器正在執行）。  | 
|  node\$1cpu\$1seconds\$1total  |  CPUs花費的總秒數 （使用者、系統、閒置等），依 CPU 和模式細分。  | 
|  node\$1disk\$1read\$1bytes\$1total  |  從磁碟成功讀取的位元組總數，依裝置細分。  | 
|  node\$1disk\$1reads\$1completed\$1total  |  磁碟成功完成的讀取總數，依裝置細分。  | 
|  node\$1disk\$1writes\$1completed\$1total  |  磁碟成功完成的寫入總數，依裝置細分。  | 
|  node\$1disk\$1written\$1bytes\$1total  |  成功寫入磁碟的位元組總數，依裝置細分。  | 
|  node\$1filesystem\$1avail\$1bytes  |  非根使用者可用的檔案系統空間，以位元組為單位，依裝置和掛載點細分。  | 
|  node\$1filesystem\$1size\$1bytes  |  檔案系統的總大小，以位元組為單位，依裝置和掛載點細分。  | 
|  node\$1filesystem\$1free\$1bytes  |  以位元組為單位的可用檔案系統空間，依裝置和掛載點細分。  | 
|  node\$1filesystem\$1files  |  檔案系統上的檔案節點 (inodes) 總數，依裝置和掛載點細分。  | 
|  node\$1filesystem\$1files\$1free  |  檔案系統上可用檔案節點 (inodes) 的數量，依裝置和掛載點細分。  | 
|  node\$1filesystem\$1readonly  |  指出檔案系統是否已掛載唯讀 (1 = 唯讀，0 = 讀寫）。  | 
|  node\$1filesystem\$1device\$1error  |  指出取得檔案系統統計資料時發生錯誤 (1 = 錯誤，0 = 成功）。  | 

## 限制
<a name="prom-msk-limitations"></a>

目前與 Amazon Managed Service for Prometheus 整合的 Amazon MSK 有下列限制：
+ 僅支援 Amazon MSK 佈建叢集 （不適用於 Amazon MSK Serverless)
+ 不支援搭配 KRaft 中繼資料模式啟用公有存取的 Amazon MSK 叢集
+ Amazon MSK Express 代理程式不支援
+ 目前支援 Amazon MSK 叢集與 Amazon Managed Service for Prometheus 收集器/工作空間之間的 1：1 映射

# 什麼是與 Prometheus 相容的指標？
<a name="prom-compatible-metrics"></a>

若要從您的應用程式和基礎設施中湊集 Prometheus 指標以用於 Amazon Managed Service for Prometheus，他們必須從與 Prometheus 相容的 `/metrics` 個端點中檢測並公開*與 Prometheus 相容的指標*。您可以建置自己的指標，但不必這樣做。Kubernetes (包括 Amazon EKS) 和許多其他程式庫和服務會直接建置這些指標。

將 Amazon EKS 中的指標匯出到與 Prometheus 相容的端點時，您可以讓 Amazon Managed Service for Prometheus 收集器自動湊集這些指標。

如需詳細資訊，請參閱下列主題：
+ 如需有關將指標匯出為 Prometheus 指標的現有程式庫和服務詳細資訊，請參閱 Prometheus 說明文件中的[匯出程式和整合](https://prometheus.io/docs/instrumenting/exporters/)。
+ 如需有關從您自己的程式碼匯出與 Prometheus 相容指標的詳細資訊，請參閱 Prometheus 文件中的[撰寫匯出程式](https://prometheus.io/docs/instrumenting/writing_exporters/)。
+ 如需有關如何設定 Amazon Managed Service for Prometheus 收集器以自動從 Amazon EKS 叢集湊集指標的詳細資訊，請參閱 [設定 Amazon EKS 的受管收集器](AMP-collector-how-to.md)。

# 使用付費日誌監控收集器
<a name="AMP-collector-vended-logs"></a>

Amazon Managed Service for Prometheus 收集器提供付費日誌，協助您監控指標收集程序並進行疑難排解。這些日誌會自動傳送至 Amazon CloudWatch Logs，並提供服務探索、指標收集和資料匯出操作的可見性。收集器會為指標收集管道的三個主要元件提供日誌：

**Topics**
+ [服務探索日誌](#amp-collector-service-discovery-vended-logs)
+ [收集器日誌](#amp-collector-vended-logs)
+ [匯出工具日誌](#amp-exporter-vended-logs)
+ [了解和使用收集器提供的日誌](#amp-collector-log-details)

## 服務探索日誌
<a name="amp-collector-service-discovery-vended-logs"></a>

服務探索日誌提供有關目標探索程序的資訊，包括：
+ 存取 Kubernetes API 資源時的身分驗證或許可問題。
+ 服務探索設定中的組態錯誤。

下列範例示範您在服務探索期間可能遇到的常見身分驗證和許可錯誤：

**不存在的 Amazon EKS 叢集**  
當指定的 Amazon EKS 叢集不存在時，您會收到下列錯誤：  

```
{
  "component": "SERVICE_DISCOVERY",
  "timestamp": "2025-04-30T17:25:41.946Z",
  "message": {
    "log": "Failed to watch Service - Verify your scraper source exists."
  },
  "scrapeConfigId": "s-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```

**無效的 服務許可**  
當收集器缺少適當的角色型存取控制 (RBAC) 許可來監看 服務時，您會收到此錯誤：  

```
{
  "component": "SERVICE_DISCOVERY",
  "timestamp": "2025-04-30T17:25:41.946Z",
  "message": {
    "log": "Failed to watch Service - Verify your scraper source permissions are valid."
  },
  "scrapeConfigId": "s-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```

**端點的無效許可**  
當收集器缺少適當的角色型存取控制 (RBAC) 許可來監看端點時，您會收到此錯誤：  

```
{
  "component": "SERVICE_DISCOVERY",
  "timestamp": "2025-04-30T17:25:41.946Z",
  "message": {
    "log": "Failed to watch Endpoints - Verify your scraper source permissions are valid."
  },
  "scrapeConfigId": "s-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```

## 收集器日誌
<a name="amp-collector-vended-logs"></a>

收集器日誌提供有關指標抓取程序的資訊，包括：
+ 由於端點無法使用而導致的擴展失敗。
+ 嘗試抓取目標時發生連線問題。
+ 湊集操作期間的逾時。
+ 湊集目標傳回的 HTTP 狀態錯誤。

下列範例示範您在指標抓取過程中可能遇到的常見收集器錯誤：

**缺少指標端點**  
當`/metrics`端點無法在目標執行個體上使用時，您會收到此錯誤：  

```
{
    "component": "COLLECTOR",
    "message": {
        "log": "Failed to scrape Prometheus endpoint - verify /metrics endpoint is available",
        "job": "pod_exporter",
        "targetLabels": "{__name__=\"up\", instance=\10.24.34.0\", job=\"pod_exporter\"}"
    },
    "timestamp": "1752787969551",
    "scraperId": "s-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```

**連線遭拒**  
當收集器無法建立與目標端點的連線時，您會收到此錯誤：  

```
{
  "scrapeConfigId": "s-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
  "timestamp": "2025-04-30T17:25:41.946Z",
  "message": {
    "message": "Scrape failed",
    "scrape_pool": "pod_exporter",
    "target": "http://10.24.34.0:80/metrics",
    "error": "Get \"http://10.24.34.0:80/metrics\": dial tcp 10.24.34.0:80: connect: connection refused"
  },
  "component": "COLLECTOR"
}
```

## 匯出工具日誌
<a name="amp-exporter-vended-logs"></a>

匯出者日誌提供有關將收集指標傳送至 Amazon Managed Service for Prometheus 工作區的程序資訊，包括：
+ 處理的指標和資料點數量。
+ 匯出因工作區問題而失敗。
+ 嘗試寫入指標時發生許可錯誤。
+ 匯出管道中的相依性失敗。

下列範例示範在指標匯出程序期間可能遇到的常見匯出工具錯誤：

**找不到工作區**  
當找不到指標匯出的目標工作區時，您會收到此錯誤：  

```
{
    "component": "EXPORTER",
    "message": {
        "log": "Failed to export to the target workspace - Verify your scraper destination.",
        "samplesDropped": 5
    },
    "timestamp": "1752787969664",
    "scraperId": "s-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```

## 了解和使用收集器提供的日誌
<a name="amp-collector-log-details"></a>

### 日誌結構
<a name="amp-log-structure"></a>

所有收集器提供的日誌都遵循與下列欄位一致的結構：

**scrapeConfigId**  
產生日誌之湊集組態的唯一識別符。

**timestamp**  
產生日誌項目的時間。

**message**  
日誌訊息內容，其中可能包含其他結構化欄位。

**元件**  
產生日誌的元件 (SERVICE\$1DISCOVERY、COLLECTOR 或 EXPORTER)

### 使用付費日誌進行故障診斷
<a name="amp-troubleshooting"></a>

收集器提供的日誌可協助您疑難排解指標收集的常見問題：

1. 服務探索問題
   + 檢查 **SERVICE\$1DISCOVERY** 日誌是否有身分驗證或許可錯誤。
   + 確認收集器具有存取 Kubernetes 資源的必要許可。

1. 指標抓取問題
   + 檢查 **COLLECTOR** 日誌是否有抓取失敗。
   + 驗證目標端點是否可存取並傳回指標。
   + 確保防火牆規則允許收集器連線到目標端點。

1. 指標匯出問題
   + 檢查 **EXPORTER** 日誌是否有匯出失敗。
   + 確認工作區存在且已正確設定。
   + 確保收集器具有寫入工作區的必要許可。

### 存取收集器提供的日誌
<a name="amp-accessing-logs"></a>

收集器提供的日誌會自動傳送至 Amazon CloudWatch Logs。若要存取這些日誌：

1. 透過 [https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/) 開啟 CloudWatch 主控台。

1. 在導覽窗格中，選擇 **Log groups** (日誌群組)。

1. 尋找並選取收集器的日誌群組：`/aws/prometheus/workspace_id/collector/collector_id`。

1. 瀏覽或搜尋日誌事件以尋找相關資訊。

您也可以使用 CloudWatch Logs Insights 來查詢和分析收集器日誌。例如，若要尋找所有服務探索錯誤：

```
fields @timestamp, message.message
| filter component = "SERVICE_DISCOVERY" and message.message like /Failed/
| sort @timestamp desc
```

### 監控收集器的最佳實務
<a name="amp-monitoring-best-practices"></a>

若要有效監控 Amazon Managed Service for Prometheus 收集器：

1. 針對關鍵收集器問題設定 CloudWatch 警示，例如持久性抓取失敗或匯出錯誤。如需詳細資訊，請參閱《*Amazon CloudWatch 使用者指南*》中的[警示](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html)。

1. 建立 CloudWatch 儀表板，以視覺化方式呈現收集器效能指標以及已佈建的日誌資料。如需詳細資訊，請參閱《*Amazon CloudWatch 使用者指南*》中的[儀表板](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

1. 定期檢閱服務探索日誌，以確保正確探索目標。

1. 監控捨棄的目標數量，以識別潛在的組態問題。

1. 追蹤匯出失敗，以確保指標成功傳送到您的工作區。