我有一个redis集群和redis导出器,在kubernetes集群的同一个命名空间中的两个独立部署中。我正在使用prometheus操作符来监视集群,但是我找不到设置导出器和操作符的方法。我已经建立了一个针对redis导出器的服务(见下文)和一个servicemonitor(见下文)。如果我将端口转发到redis exporter服务,我可以看到度量。此外,redis exporter日志不显示问题。
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: foo
name: redis-exporter
labels:
app: redis-exporter
spec:
replicas: 1
selector:
matchLabels:
app: redis-exporter
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9121"
labels:
app: redis-exporter
spec:
containers:
- name: redis-exporter
image: oliver006/redis_exporter:latest
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: REDIS_ADDR
value: redis-cluster.foo.svc:6379
ports:
- containerPort: 9121
我的服务和服务监视器
kind: Service
metadata:
name: redis-external-exporter
namespace: foo
labels:
app: redis
k8s-app: redis-ext
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: "9121"
spec:
ports:
- name: redis-ext
port: 9121
protocol: TCP
targetPort: 9121
selector:
app: redis-exporter
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: redis-external-exporter
namespace: bi-infra
labels:
app: redis-external-exporter
k8s-app: redis-monitor
spec:
jobLabel: app
selector:
matchLabels:
app: redis-ext
namespaceSelector:
matchNames:
- foo
endpoints:
- port: redis-ext
interval: 30s
honorLabels: true
如果我切换到redis集群旁边的sidecar redis exporter,那么一切都正常工作。有人面临过这样的问题吗?
1条答案
按热度按时间raogr8fs1#
我在servicemonitor上缺少spec.endpoints.path
下面是一个例子清单添加新的刮目标和疑难解答教程。