信息
prometheus v2.1.0
redis_exporter v1.6.1
redis cluster 5.0 3 mater 3 slave
prometheus.yml
在prometheus.yml添加两个job,redis_exporter和redis_exporter_targets,redis_exporter_targets才是真正监控redis集群的。
## config for scraping the exporter itself
- job_name: 'redis_exporter'
static_configs:
- targets:
- prod-xxx-xxxx-redis01:9121
## config for the multiple Redis targets that the exporter will scrape
- job_name: 'redis_exporter_targets'
static_configs:
- targets:
- redis://172.16.0.122:7000
- redis://172.16.0.122:7001
- redis://172.16.0.120:7002
- redis://172.16.0.120:7003
- redis://172.16.0.129:7004
- redis://172.16.0.129:7005
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: prod-xxxx-xxxx-redis01:9121
docker部署redis_exporter
REDIS_ADDR为你redis集群的其中一个节点即可,默认redis_exporter 使用9121端口!!
docker run -d -e REDIS_ADDR=172.16.0.120:7002 -e REDIS_PASSWORD=123456 --name redis_exporter --restart=always -p 9121:9121 oliver006/redis_exporter
然后重启prometheus。
grafana模板
id 763
没有数据的话到prometheus 9090端口的target看看我们新建的job target 是否 为 up 的状态。
kubectl get svc -n test |grep redis cloud-redis NodePort 10.96.64.81 <none> 6379:31379/TCP 265d cloud-redis-0 NodePort 10.96.255.163 <none> 6379:31380/TCP 64d cloud-redis-1 NodePort 10.96.181.147 <none> 6379:31381/TCP 64d cloud-redis-2 NodePort 10.96.203.189 <none> 6379:31382/TCP 64d cloud-redis-3 NodePort 10.96.155.12 <none> 6379:31383/TCP 64d cloud-redis-4 NodePort 10.96.249.50 <none> 6379:31384/TCP 64d cloud-redis-5 NodePort 10.96.179.124 <none> 6379:31385/TCP 64d
prometheus 显示的targets
参考文档:
https://www.jianshu.com/p/2ead2f0dd325