[英]Connect redis exporter and prometheus operator
I have a Redis cluster and Redis-exporter in two separate deployments in the same namespace of a Kubernetes cluster.我在 Kubernetes 集群的同一命名空间中的两个单独部署中有一个 Redis 集群和 Redis-exporter。 I am using Prometheus operator to monitor the cluster, but I can not find a way to set up the exporter and the operator.我正在使用 Prometheus 算子来监控集群,但我找不到设置导出器和算子的方法。 I have set up a service targeting the Redis exporter(check below) and a ServiceMonitor(also below).我已经建立了一个针对 Redis 导出器的服务(检查下面)和一个 ServiceMonitor(也在下面)。 If I port forward to the Redis exporter service I can see the metrics.如果我转发到 Redis 导出器服务,我可以看到指标。 Also, the Redis exporter logs do not show issues.此外,Redis 导出器日志不会显示问题。
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
My service and servicemonitor我的服务和服务监视器
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
If I switch to a sidecar Redis exporter next to the Redis cluster all is working properly.如果我切换到 Redis 集群旁边的 Sidecar Redis 导出器,则一切正常。 Has anyone faced such issue?有没有人遇到过这样的问题?
I was missing spec.endpoints.path on the ServiceMonitor我在 ServiceMonitor 上缺少 spec.endpoints.path
Here is an example manifest from adding new scraping targets and troubleshooting tutorial .这是添加新抓取目标和故障排除教程的示例清单。
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: monitoring-pili
namespace: monitoring
labels:
app: pili-service-monitor
spec:
selector:
matchLabels:
# Target app service
app: pili
endpoints:
- interval: 15s
path: /metrics <---
port: uwsgi
namespaceSelector:
matchNames:
- default
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.