gpt4 book ai didi

kubernetes - 连接Redis导出器和Prometheus运算符

转载 作者:行者123 更新时间:2023-12-02 12:09:32 24 4
gpt4 key购买 nike

我在Kubernetes集群的同一 namespace 中的两个单独的部署中都有一个Redis集群和Redis-exporter。我正在使用Prometheus运算符监视群集,但是找不到设置导出程序和运算符的方法。我已经设置了一个针对Redis导出器的服务(在下面检查)和一个ServiceMonitor(也在下面)。如果我转发到Redis导出器服务,则可以看到指标。另外,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
我的服务和服务监视器
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导出器,则一切正常。有没有人遇到过这样的问题?

最佳答案

我在ServiceMonitor上缺少spec.endpoints.path
这是添加新的抓取目标并对tutorial进行故障排除的示例 list 。

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

关于kubernetes - 连接Redis导出器和Prometheus运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64336169/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com