1、准备exporter
https://github.com/oliver006/redis_exporter
oliver006-redis_exporter-amd64.tar
# 安装镜像
docker load -i oliver006-redis_exporter-amd64.tar
# 上传镜像
docker tag oliver006/redis_exporter ip/monitor/redis_exporter:latest
docker push ip/monitor/redis_exporter:latest
2、部署exporter
kind: Deployment
apiVersion: apps/v1
metadata:
name: redis-exporter
namespace: devops
labels:
app: redis-exporter
annotations:
deployment.kubernetes.io/revision: '1'
kubesphere.io/creator: admin
kubesphere.io/description: 监控使用
spec:
replicas: 1
selector:
matchLabels:
app: redis-exporter
template:
metadata:
labels:
app: redis-exporter
annotations:
kubesphere.io/containerSecrets: '{"container-zsbagq":"harbor"}'
spec:
containers:
- name: container-zsbagq
image: 'ip:8888/monitor/redis_exporter:latest'
args:
- '-redis.addr'
- 'redis-hip-redis-cluster-headless.hip-mid:6379'
- '-redis.password'
- '111111'
ports:
- name: tcp-9121
containerPort: 9121
protocol: TCP
imagePullPolicy: IfNotPresent
restartPolicy: Always
imagePullSecrets:
- name: harbor
3、创建serviceMonitor
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: redis-exporter
name: redis-exporter
namespace: devops
spec:
endpoints:
- interval: 30s
port: tcp-9121
params:
target:
- redis-hip-redis-cluster-headless.hip-mid:6379
relabelings:
- sourceLabels: [__param_target]
targetLabel: instance
selector:
matchLabels:
app: redis-exporter
namespaceSelector:
matchNames:
- devops
创建成功,访问prometheus targets界面,显示如图
4、grafana模板
id:17507
以上内容对您有帮助,请点赞支持,谢谢!