Prometheus Operator自定义监控项
Prometheus Operator默认的监控指标并不能完全满足实际的监控需求,这时候就需要我们自己根据业务添加自定义监控。添加一个自定义监控的步骤如下: 1、创建一个ServiceMonitor对象,用于Prometheus添加监控项 2、为ServiceMonitor对象关联metrics数据接口的Service对象 3、确保Services对象可以正确获取到metrics数据 下面本文将以如何添加redis监控为例 部署redis k8s-redis-and-exporter-deployment.yaml --- apiVersion: v1 kind: Namespace metadata: name: redis --- apiVersion: apps/v1 kind: Deployment metadata: namespace: redis name: redis spec: replicas: 1 selector: matchLabels: app: redis template: metadata: annotations: prometheus.io/scrape: "true" prometheus.io/port: "9121" labels: app: redis spec: containers: - name: redis image: