使用 Prometheus 遠端寫入來收集度量值
您可以配置 Prometheus 遠端寫入,以從無法使用 Monitoring 代理程式的環境收集度量值,並將它們傳送至 Monitoring 實例。
您可以從下列收集度量:
- 現有的 Prometheus 伺服器。
- 暫時或批次工作可能不夠長,無法由 Monitoring 代理程式提取。
- 無法使用 Monitoring 代理程式的 Windows 主機及其他作業系統
- Non-x86 型架構,通常在 IoT 環境或 Edge 運算上可見。
- 非容器化工作負載,例如 NGNIX、自訂應用程式、RabbitMQ,和別的。
您可以透過 Monitoring Web 使用者介面,監視使用 Prometheus 遠端寫入所收集的度量值。 您也可以使用 PromQL,透過使用標準 Prometheus 查詢語言來查詢資料。
配置 Prometheus 遠端寫入
您可以將 Prometheus 伺服器配置為遠端寫入 Monitoring 實例。 例如,
-
您可以不同方式配置在 Kubernetes 叢集中執行的 Prometheus 伺服器。 視您如何安裝它而定,您可以選擇下列任何選項來配置 Prometheus 中的遠端寫入特性,以將度量值傳送至 IBM Cloud Monitoring 實例:
-
配置 Prometheus 操作器所管理的 Prometheus 伺服器
-
使用 Helm 來配置 Prometheus 伺服器
-
透過 Kubernetes ConfigMap 來配置 Prometheus 伺服器
如需詳細資訊,請參閱 使用 Prometheus remote write 收集度量資訊。
-
Prometheus v2.25 及舊版
若為 Prometheus v2.25 及舊版,您必須在 prometheus.yml 配置檔中配置 remote_write 區段,如下所示:
global:
external_labels:
[ <labelname>: <labelvalue> ... ]
remote_write:
- url: "https://<INGESTION_URL>/prometheus/remote/write"
bearer_token: "<MONITOR_API_TOKEN>"
其中
<MONITOR_API_TOKEN>包含授權記號。 如需相關資訊,請參閱 使用 Monitor API 記號。<INGESTION_URL>表示攝取端點。 您必須將此值設為可以使用 Monitoring 實例之地區的汲取端點。 如需相關資訊,請參閱 端點。
Prometheus 2.26 版以及更新版本
對於 Prometheus 2.26 版以及更新版本,您必須在 prometheus.yml 配置檔中配置 remote_write 區段,如下所示:
global:
external_labels:
[ <labelname>: <labelvalue> ... ]
remote_write:
- url: "https://<INGESTION_URL>/prometheus/remote/write"
authorization:
credentials: "<MONITOR_API_TOKEN>"
其中
<MONITOR_API_TOKEN>包含授權記號。 如需相關資訊,請參閱 使用 Monitor API 記號。<INGESTION_URL>表示攝取端點。 您必須將此值設為可以使用 Monitoring 實例之地區的汲取端點。 如需相關資訊,請參閱 端點。
管理透過遠端寫入收集的度量值
依預設,當您將 Prometheus 伺服器配置為遠端寫入 Monitoring 實例時,會收集所有度量值並包含 remote_write: true 標籤以輕鬆識別它們。
控制傳送的度量值
您可以管理及控制收集並傳送至 Monitoring 實例的度量值。 若要選取要收集的系列及標籤,並減少傳送至 Monitoring 實例的作用中系列數目,您可以使用 remote_write 區段內的 write_relabel_configs 區塊來設定重新標示配置。
例如,若要從 1 個名稱空間 my-namespace 收集度量值,您可以新增下列:
remote_write:
- url: https://<INGESTION_URL>/prometheus/remote/write
authorization:
credentials_file: /etc/secrets/<SECRET_NAME>
write_relabel_configs:
- action: keep
regex: my-namespace
source_labels:
- namespace
依 Prometheus 伺服器標示度量值
您可以指定隨 Prometheus 伺服器使用 global 內的 external_labels 區塊所收集的每一個時間序列一起傳送的自訂標籤。
您可以使用這些標籤來過濾及定義您在 Monitoring 使用者介面中透過儀表板監視的度量值範圍。
例如,如果您有 2 個不同的 Prometheus 伺服器配置為遠端寫入 Monitoring 實例,則可以包括外部標籤來識別每一部伺服器:
# Prometheus server 1
global:
external_labels:
provider: prometheus1
remote_write:
- url: ...
# Prometheus server 2
global:
external_labels:
provider: prometheus2
remote_write:
- url: ...
速率限制
下表列出每個實例的預設速率限制:
| 速率 | 限制 | 資訊 |
|---|---|---|
| 平行寫入 | 100 個並行要求 | |
| 每分鐘資料點數 (DPM) | 1 百萬 | 傳送的資料點數目取決於傳送度量的頻率。 例如,提取間隔 10s 將提交比間隔 60 秒更多的 DPM |
| 每分鐘寫入次數 | 10,000 |
遠端寫入的汲取端點
IBM Cloud Monitoring 已淘汰 https://ingest.<region> 和 https://ingest.private.<region> 格式之端點的 Prometheus 用戶端支援,並在 2024 年 5 月 31 日將它們取代為新的端點。 舊端點的支援將於 2024 年 8 月 31 日終止。 在此日期之後,舊端點將停止工作。 客戶使用Prometheus遠端寫入需要在
2024 年 8 月 31 日之前遷移到使用新端點才能繼續使用Prometheus遠端寫入。
下表列出您可以配置以透過 Prometheus 遠端寫入來收集度量值的公用 Monitoring 汲取端點:
遠端寫入汲取使用 TCP 443 埠。
| 地區 | 端點 |
|---|---|
達拉斯 (US-South) |
https://ingest.us-south.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.us-south.monitoring.cloud.ibm.com/prometheus/remote/write |
法蘭克福 (EU-DE) |
https://ingest.eu-de.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.eu-de.monitoring.cloud.ibm.com/prometheus/remote/write |
倫敦 (EU-GB) |
https://ingest.eu-gb.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.eu-gb.monitoring.cloud.ibm.com/prometheus/remote/write |
馬德里 (EU-ES) |
https://ingest.eu-es.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.eu-es.monitoring.cloud.ibm.com/prometheus/remote/write |
大阪 (JP-OSA) |
https://ingest.jp-osa.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.jp-osa.monitoring.cloud.ibm.com/prometheus/remote/write |
聖保羅 (BR-SAO) |
https://ingest.br-sao.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.br-sao.monitoring.cloud.ibm.com/prometheus/remote/write |
悉尼 (AU-SYD) |
https://ingest.au-syd.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.au-syd.monitoring.cloud.ibm.com/prometheus/remote/write |
東京 (JP-TOK) |
https://ingest.jp-tok.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.jp-tok.monitoring.cloud.ibm.com/prometheus/remote/write |
多倫多 (CA-TOR) |
https://ingest.ca-tor.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.ca-tor.monitoring.cloud.ibm.com/prometheus/remote/write |
華盛頓(US-EAST) |
https://ingest.us-east.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.us-east.monitoring.cloud.ibm.com/prometheus/remote/write |
下表列出您可以配置以透過 Prometheus 遠端寫入來收集度量值的專用 Monitoring 汲取端點:
| 地區 | 端點 |
|---|---|
達拉斯 (US-South) |
https://ingest.private.us-south.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.us-south.monitoring.cloud.ibm.com/prometheus/remote/write |
法蘭克福 (EU-DE) |
https://ingest.private.eu-de.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.eu-de.monitoring.cloud.ibm.com/prometheus/remote/write |
倫敦 (EU-GB) |
https://ingest.private.eu-gb.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.eu-gb.monitoring.cloud.ibm.com/prometheus/remote/write |
馬德里 (EU-ES) |
https://ingest.private.eu-es.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.eu-es.monitoring.cloud.ibm.com/prometheus/remote/write |
大阪 (JP-OSA) |
https://ingest.private.jp-osa.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.jp-osa.monitoring.cloud.ibm.com/prometheus/remote/write |
聖保羅 (BR-SAO) |
https://ingest.private.br-sao.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.br-sao.monitoring.cloud.ibm.com/prometheus/remote/write |
悉尼 (AU-SYD) |
https://ingest.private.au-syd.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.au-syd.monitoring.cloud.ibm.com/prometheus/remote/write |
東京 (JP-TOK) |
https://ingest.private.jp-tok.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.jp-tok.monitoring.cloud.ibm.com/prometheus/remote/write |
多倫多 (CA-TOR) |
https://ingest.private.ca-tor.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.ca-tor.monitoring.cloud.ibm.com/prometheus/remote/write |
華盛頓(US-EAST) |
https://ingest.private.us-east.monitoring.cloud.ibm.com/prometheus/remote/write 已淘汰https://ingest.prws.private.us-east.monitoring.cloud.ibm.com/prometheus/remote/write |
限制
IBM Cloud Monitoring Prometheus「遠端寫入」特性具有下列限制:
-
傳送至實例的度量值可以在「探索」中存取,但與範圍樹狀結構不相容。
-
只能使用在來源中收集的標籤來過濾度量值。
-
度量的 meta 資料不是透過遠端寫入來傳送。
-
名稱以
_total、_sum或_count結尾的度量會儲存為計數器,否則它們會作為量規進行管理。 -
您可以在儀表板中手動設定單元。
-
您無法在儀表板中混合度量值與不同的取樣,例如 10s 和 1min。
請考量將提取間隔配置為 10s,以便您可以結合 Prometheus「遠端寫入」度量值與 Monitoring 代理程式度量值。