Redis-exporter
服务端口:9121
部署
安装包:redis_exporter-v1.33.0.linux-amd64.tar.gz
运行条件:go环境
安装go:
yum install -y epel-release
yum install -y golang
下载安装包
https://github.com/oliver006/redis_exporter/releases
解压
解压重命名redis_exporter-v1.33.0.linux-amd64.tar.gz文件夹后,配置redis_exporter.service,就能用。
配置redis_exporter.service
vim /etc/systemd/system/redis_exporter.service
[Unit]
Description=redis_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/redis_exporter-v1.33.0.linux-amd64/redis_exporter -redis.addr {部署predixy代理的ip}:7617 -redis.password XXXXX -web.listen-address {部署redis_exporter服务的ip}:9121
Restart=always
启动
加入prometheus
vim /etc/prometheus/prometheus.yml
- job_name: 'GT_WORK_REDIS_CULSTER'
static_configs:
- targets:
- redis://192.168.10.1:7001
- redis://192.168.10.2:7002
- redis://192.168.10.3:7003
- redis://192.168.10.4:7004
- redis://192.168.10.5:7005
- redis://192.168.10.6:7006
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: xxx.xxx.xxx.xxx:9121
配置告警规则
vim /etc/prometheus/rules/redis.yml
groups:
- name: redis
rules:
- alert: RedisDown
annotations:
description: |-
Redis instance is down
VALUE = {{ $value }}
LABELS: {{ $labels }}
summary: Redis down (instance {{ $labels.instance }})
expr: redis_up == 0
for: 5m
labels:
severity: critical
- alert: RedisOutOfMemory
annotations:
description: |-
Redis is running out of memory (> 85%)
VALUE = {{ $value }}
LABELS: {{ $labels }}
summary: Redis out of memory (instance {{ $labels.instance }})
expr: redis_memory_used_bytes / redis_total_system_memory_bytes * 100 > 85
for: 5m
labels:
severity: warning
- alert: RedisTooManyConnections
annotations:
description: |-
Redis instance has too many connections
VALUE = {{ $value }}
LABELS: {{ $labels }}
summary: Redis too many connections (instance {{ $labels.instance }})
expr: redis_connected_clients > 100
for: 5m
labels:
severity: warning
记得重启prometheus
Grafana导入模板
两种方法:
第一种是本地有redis的模板,直接导入
第二种是搜索编号并直接下载