本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
設定 Amazon OpenSearch Service 的受管 Prometheus 收集器
適用於 Amazon OpenSearch Service 的 Amazon Managed Service for Prometheus 受管收集器會自動從您的 OpenSearch Service 網域抓取與 Prometheus 相容的指標,並將其轉送到您的目的地。Amazon Managed Service for Prometheus 會為您管理收集器,為您提供所需的可擴展性、安全性和可靠性,而無需自行管理任何執行個體、代理程式或抓取器。您的目的地可以是 Amazon Managed Service for Prometheus 工作區或 Amazon CloudWatch。
您也可以建立與 Amazon Elastic Kubernetes Service 或 Amazon Managed Streaming for Apache Kafka 整合的抓取器。如需詳細資訊,請參閱整合 Amazon EKS 和整合 Amazon MSK。
建立湊集器
此程序假設您熟悉 Amazon OpenSearch Service 網域管理和 Amazon Virtual Private Cloud 網路概念。
為 OpenSearch Service 網域建立抓取器有幾個先決條件:
-
具有 Amazon Virtual Private Cloud 存取權的 Amazon OpenSearch Service 網域。受管收集器僅支援具有 VPC 存取權的 OpenSearch Service 網域。不支援具有公有存取權的網域。
-
允許受管收集器透過 HTTPS (連接埠 443) 到達 OpenSearch Service 網域端點的安全群組。將傳入規則新增至網域的安全群組,以允許來自您為收集器提供的安全群組的 HTTPS 流量。
若要告知抓取器要從哪個 OpenSearch Service 網域收集,請在請求的 exporters 欄位中指定網域。exporters 欄位會取得匯出工具組態的清單;對於 OpenSearch Service 網域,請提供 網域domainArn的 openSearchConfiguration 。您可以在 source 欄位中分別提供聯網 (子網路和安全群組),如下列範例所示。
當您建立抓取器時,抓取器會使用已解析的網域 VPC 端點。如果您重新建立網域,它會取得新的端點,因此您必須建立新的抓取器,或使用 UpdateScraper 更新現有的抓取器以從中收集。
您在建立抓取器時提供抓取組態。受管收集器會連線至您指定的網域,並自動收集其指標,因此您不會在組態中指定湊集目標。組態必須包含任務剛好job_name為 的scrape_configs區段opensearch-exporter。不包含名為 之任務的組態opensearch-exporter會遭到拒絕。使用抓取組態來設定抓取間隔,並選擇性地篩選或重新標記收集的指標。以下是抓取組態的範例:
global: external_labels: domain_name:my-opensearch-domainscrape_configs: - job_name: opensearch-exporter scrape_interval: 60s
如需支援的湊集組態選項的詳細資訊,請參閱 湊集器組態。
-
以下是您可以搭配 AWS API 使用的湊集器操作完整清單:
使用 CreateScraper API 操作建立抓取器。
-
使用 ListScrapers API 操作列出現有的抓取器。
-
使用 UpdateScraper API 操作更新抓取器的別名、組態或目的地。
-
使用 DeleteScraper API 操作刪除抓取器。
-
使用 DescribeScraper API 操作取得有關抓取器的詳細資訊。
跨帳戶設定
若要在跨帳戶設定中建立抓取器,當您要從中收集指標的 OpenSearch Service 網域位於與 Amazon Managed Service for Prometheus 收集器不同的帳戶中時,請使用下列程序。
例如,您有兩個帳戶:account_id_sourceOpenSearch Service 網域所在的來源帳戶,以及 account_id_target Amazon Managed Service for Prometheus 工作區所在的目標帳戶。
下列步驟中的信任政策會參照抓取器的 ARN,其中包含在您建立抓取器之前不存在的抓取器 ID。若要避免此排序問題,請先使用萬用字元 (scraper/*) 建立角色來取代特定抓取器 ARN、建立抓取器,然後更新兩個信任政策,以使用CreateScraper傳回的實際抓取器 ARN 取代萬用字元。
在跨帳戶設定中建立抓取器
-
在來源帳戶中,建立角色
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" } } } -
在目標帳戶中,建立角色
arn:aws:iam::並新增下列信任政策,以允許來源角色擔任該角色。444455556666:role/Target{ "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" } } }將許可政策連接至目標角色,以允許它寫入您的目的地。如果您的目的地是 Amazon Managed Service for Prometheus 工作區,請連接 AmazonPrometheusRemoteWriteAccess (授予
aps:RemoteWrite)。如果您的目的地是 Amazon CloudWatch,請連接在資料集cloudwatch:PutMetricData上授予 的政策。 -
使用
--role-configuration選項建立抓取器。aws amp create-scraper \ --source '{"vpcConfiguration":{"securityGroupIds":["sg-security-group-id"],"subnetIds":["subnet-subnet-id-1","subnet-subnet-id-2"]}}' \ --exporters '[{"openSearchConfiguration":{"domainArn":"arn:aws:es:aws-region:111122223333:domain/my-opensearch-domain"}}]' \ --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"}' -
驗證抓取器的建立。
aws amp list-scrapers
尋找並刪除湊集器
您可以使用 AWS API 或 AWS CLI 列出您帳戶中的抓取器或刪除它們。
請確定您使用的是最新版本的 AWS CLI 或 SDK。最新版本提供最新的功能和功能,以及安全性更新。或者,使用 AWS CloudShell,它會自動提供up-to-date命令列體驗。
若要列出您帳戶中的所有抓取器,請使用 ListScrapers API 操作。或者,使用 AWS CLI呼叫:
aws amp list-scrapers
若要刪除抓取器,請使用 ListScrapers操作尋找您要刪除之抓取器scraperId的 ,然後使用 DeleteScraper 操作將其刪除。或者,使用 AWS CLI呼叫:
aws amp delete-scraper --scraper-idscraperId
從 Amazon OpenSearch Service 收集的指標
當您與 Amazon OpenSearch Service 整合時,Amazon Managed Service for Prometheus 收集器會自動抓取描述網域運作狀態和效能的 Prometheus 相容指標。收集器會發出數百個指標;下表列出每個類別的代表性指標。下表中的opensearch_indices_指標會跨網域彙總,許多 具有僅限主要變體和總變體 (尾碼為 _primary或 _total)。收集器也會針對每個索引、字首 opensearch_index_stats_和字首為 的每個碎片指標發出相同的統計資料opensearch_indices_shards_。
| 指標 | 描述/目的 |
|---|---|
opensearch_cluster_health_status |
叢集運作狀態 (綠色、黃色或紅色)。 |
opensearch_cluster_health_number_of_nodes |
叢集中的節點數量。 |
opensearch_cluster_health_number_of_data_nodes |
叢集中的資料節點數量。 |
opensearch_cluster_health_active_primary_shards |
作用中主要碎片的數量。 |
opensearch_cluster_health_active_shards |
作用中碎片的總數,包括主要碎片和複本碎片。 |
opensearch_cluster_health_relocating_shards |
在節點之間重新定位的碎片數量。 |
opensearch_cluster_health_initializing_shards |
正在初始化的碎片數量。 |
opensearch_cluster_health_unassigned_shards |
未指派給節點的碎片數量。 |
opensearch_cluster_health_delayed_unassigned_shards |
指派延遲的未指派碎片數量。 |
opensearch_cluster_health_number_of_pending_tasks |
已排入佇列並等待執行的叢集層級任務數量。 |
opensearch_cluster_health_number_of_in_flight_fetch |
進行中碎片擷取請求的數量。 |
opensearch_cluster_health_task_max_waiting_in_queue_millis |
任務在佇列中等待的最長時間,以毫秒為單位。 |
| 指標 | 描述/目的 |
|---|---|
opensearch_os_cpu_percent |
節點上作業系統使用的 CPU 百分比。 |
opensearch_os_load1 |
過去 1 分鐘的作業系統負載平均值。收集器也會發出 |
opensearch_os_mem_used_bytes |
使用的實體記憶體數量,以位元組為單位。收集器也會發出 |
opensearch_jvm_memory_used_bytes |
記憶體區域 (堆積和非堆積) 所使用的 JVM 記憶體數量,以位元組為單位。相關指標包括 |
opensearch_jvm_gc_collection_seconds_count |
JVM 垃圾回收事件的總數。與 搭配使用 |
opensearch_jvm_uptime_seconds |
JVM 執行時間,以秒為單位。 |
opensearch_thread_pool_active_count |
每個執行緒集區中的作用中執行緒數量。相關指標包括 |
opensearch_filesystem_data_available_bytes |
節點可用的磁碟空間量,以位元組為單位。相關指標包括 |
opensearch_filesystem_io_stats_device_read_operations_count |
磁碟讀取操作的數量。收集器也會發出寫入和總操作計數,以及讀取和寫入大小 (例如 |
opensearch_process_cpu_percent |
OpenSearch 程序使用的 CPU 百分比。 |
opensearch_process_mem_resident_size_bytes |
OpenSearch 程序的駐留記憶體大小,以位元組為單位。 |
opensearch_process_open_files_count |
OpenSearch 程序開啟的檔案描述項數量。 |
opensearch_breakers_tripped |
每個斷路器觸發的總次數。相關指標包括 |
opensearch_transport_rx_size_bytes_total |
節點之間透過傳輸層接收的資料總量,以位元組為單位。收集器也會發出 |
opensearch_indexing_pressure_current_all_in_bytes |
將請求編製索引所耗用的目前記憶體,以位元組為單位,並以 |
| 指標 | 描述/目的 |
|---|---|
opensearch_indices_docs |
文件數量。相關指標包括 |
opensearch_indices_store_size_bytes |
磁碟上的索引總大小,以位元組為單位,使用 |
opensearch_indices_indexing_index_total |
編製索引的文件總數。使用 搭配 |
opensearch_indices_indexing_is_throttled |
指出索引目前是否受到限流, |
opensearch_indices_search_query_total |
搜尋查詢的總數。使用 搭配 |
opensearch_indices_search_fetch_total |
擷取操作的總數,使用 |
opensearch_indices_get_total |
取得操作總數,使用 |
opensearch_indices_merges_total |
已完成的區段合併總數。相關指標包括 |
opensearch_indices_refresh_total |
索引重新整理操作的總數,使用 |
opensearch_indices_flush_total |
索引排清操作的總數,使用 |
opensearch_indices_segments_count |
區段數量。收集器也會發出每個區段的記憶體指標 (例如 |
opensearch_indices_translog_operations |
交易日誌中的操作數量,其中 |
opensearch_indices_fielddata_memory_size_bytes |
欄位資料快取使用的記憶體,以位元組為單位,搭配 |
opensearch_indices_query_cache_memory_size_bytes |
查詢快取使用的記憶體,以位元組為單位。相關指標包括 |
opensearch_indices_request_cache_memory_size_bytes |
請求快取使用的記憶體,以位元組為單位。相關指標包括 |
限制
Amazon OpenSearch Service 與 Amazon Managed Service for Prometheus 整合有下列限制:
-
僅支援具有 Amazon Virtual Private Cloud 存取權的 OpenSearch Service 網域。不支援具有公有存取權的網域。
-
湊集器會從單一 OpenSearch Service 網域收集指標。若要從多個網域收集指標,請為每個網域建立個別的抓取器。