Prometheus 監控
更新時間 2025-07-03 21:54:34
最近更新時間: 2025-07-03 21:54:34
分享文章
本節介紹Prometheus監控。
前提條件
分布式容器云平臺的集群監控已對接應用性能監控。
已創建注冊集群,具體操作參見 注冊集群。
操作步驟
開啟Prometheus監控
登錄分布式容器云平臺,進入集群管理頁。
在集群管理頁點擊需要查看監控的注冊集群,進入集群信息頁面。
在注冊集群詳情頁面選擇 運維管理->Prometheus監控,若未開通Prometheus監控服務,請按照頁面指引進行 委托受理 ->開通應用性能監控->打通應用性能監控網絡訪問->安裝cube-prometheus插件。
完成操作之后即可進入Prometheus監控頁面,查看分布式容器云平臺提供的預設Grafana面板,包括集群概覽、核心組件、節點、應用和網絡監控,用戶可對預設面板進行修改,根據需求定制自己的監控面板。
工作負載接入監控
登錄應用性能監控控制臺,點擊進入Prometheus監控->接入管理,點擊已接入環境對應的單集群。
在單集群對應的接入管理詳情頁面,進入指標采集->功能啟用,啟用后開始收費,對自定義指標上報,使用ServiceMonitor或PodMonitor服務發現方式進行指標上報。
新增ServiceMonitor
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: service-monitor1
namespace: ns1
annotations:
arms.prometheus.io/discovery: 'true'
spec:
endpoints:
- interval: 60s
port: metrics # 對應Service中定義的端口名稱
path: /metrics
namespaceSelector:
any: true # 監控所有命名空間
selector:
matchLabels:
app: app1或者選用新增PodMonitor
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: pod-monitor1
namespace: ns1
annotations:
arms.prometheus.io/discovery: 'true'
spec:
selector:
matchLabels:
app: app1 # 匹配目標pod的標簽
namespaceSelector:
any: true
podMetricsEndpoints:
- interval: 60s
targetPort: 8080
path: /metrics
驗證監控指標上報情況,在指標探索頁進行搜索對應指標。