Prometheus 监控
更新时间 2025-06-19 20:03:16
最近更新时间: 2025-06-19 20:03:16
本节介绍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
验证监控指标上报情况,在指标探索页进行搜索对应指标。