redis-exporter监控Redis
一、单节点监控
#启动,密码带特殊字符时需要用\进行转义
docker run -dit -p 9121:9121 -e REDIS_ADDR=IP:6379 -e REDIS_PASSWORD=password --name=redis-exporter redis-exporter:v1.27.0-arm64
docker logs --tail=100
##以下日志表明已经正确连接到redis
time="2020-08-02T13:46:50+08:00" level=info msg="Redis Metrics Exporter v1.9.0 build date: 2020-07-07-02:25:01 sha1: 3e15a27ef8657e77100a55f10895e1a4fee70f79 Go: go1.14.4 GOOS: linux GOARCH: amd64"
time="2020-08-02T13:46:50+08:00" level=info msg="Providing metrics at :9121/metrics"
##若出现以下日志,redis未正确连接。考虑查看redis.conf 的bind参数是否与redis—exporter中的redis.addr参数一致
time="2020-08-02T13:46:24+08:00" level=error msg="Couldn't connect to redis instance"
修改prometheus.yml
- job_name: redis_exporter
static_configs:
- targets: ['192.168.100.104:9121']
二、集群监控
https://www.cnblogs.com/fsckzy/p/12053604.html
启动一个redis-exporter即可,prometheus.yml按照如下配置。
- job_name: 'redis_exporter_targets'
static_configs:
- targets:
- redis://10.1.1.101:6379
- redis://10.1.1.101:6380
- redis://10.1.1.102:6379
- redis://10.1.1.102:6380
labels:
region: QWE #添加标签
project: QAZ
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.1.101:9122
- job_name: 'Redis-exporter监控'
metrics_path: '/metrics'
static_configs:
- targets: ['172.16.45.8:9121']
标签:__,9121,exporter,target,Redis,08,redis,Prometheus,监控
From: https://www.cnblogs.com/light-year/p/16823431.html