Prometheus 监控 Redis
2019-06-02 本文已影响0人
awker
1、下载 redis exporter
// 下载地址:https://github.com/oliver006/redis_exporter/releases
# ls redis_exporter-v1.0.0.linux-amd64.tar.gz
redis_exporter-v1.0.0.linux-amd64.tar.gz
# tar xvf redis_exporter-v1.0.0.linux-amd64.tar.gz -C /usr/local/
2、配置 redis_exporter
2.1 添加账号授权给 redis exporter,以便 redis_exporter 能够连接到 redis server
2.2 配置 redis_exporter service 文件
# vim /etc/systemd/system/redis_exporter.service
[Unit]
Description=redis_exporter
After=network.target
[Service]
Restart=on-failure
ExecStart=/usr/local/redis_exporter-v1.0.0.linux-amd64/redis_exporter -redis.addr 192.168.22.33:6379 -redis.password 123456
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start redis_exporter
# systemctl status redis_exporter
-redis.addr 192.168.22.33:6379 -redis.password 123456 --> 配置 redis 连接信息
3、 查看采集到的数据
4、添加 prometheus 监控
# vim prometheus.yml
- file_sd_configs:
- files:
- 'configs/redis.yml'
job_name: Redis
metrics_path: /metrics
relabel_configs:
- source_labels: [__address__]
regex: (.*)
target_label: instance
replacement: $1
- source_labels: [__address__]
regex: (.*)
target_label: __address__
replacement: $1:9121
# vim configs/redis.yml
- labels:
service: redis_192.168.22.33
targets:
- 192.168.22.11
5、 配置 grafana 展示
从 https://grafana.com/dashboards/763 下载 json 文件,导入 grafana,根据需求调整即可。