cd /usr/local/src
wget https://github.com/oliver006/redis_exporter/releases/download/v1.55.0/redis_exporter-v1.55.0.linux-amd64.tar.gz
mv redis_exporter-v1.55.0.linux-amd64 /data/redis_exporter
-redis.addr:指明一个或多个 Redis 节点的地址,多个节点使用逗号分隔,默认为 redis://localhost:6379
-redis.password:验证 Redis 时使用的密码;
-redis.file:包含一个或多个redis 节点的文件路径,每行一个节点,此选项与 -redis.addr 互斥。
-web.listen-address:监听的地址和端口,默认为 0.0.0.0:912
## 无密码
nohup ./redis_exporter redis//r-3nsfvqew8gr0wrr6ko.redis.rds.aliyuncs.com:6379 &
## 有密码
nohup redis_exporter -redis.addr 1.1.1.1:6379 -redis.user exporter -redis.password Qwe123456 -redis-only-metrics &
cat >> /usr/lib/systemd/system/redis_exporter.service << EOF
[Unit]
Description=redis_exporter
After=network.target
[Service]
Type=simple
ExecStart=/data/redis_exporter/redis_exporter -redis.addr 1.1.1.1:6379 -redis.user exporter -redis.password Qwe123456 -redis-only-metrics
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable redis_exporter
systemctl start redis_exporter
systemctl status redis_exporter
ss -antpl |grep 9121
LISTEN 0 128 [::]:9121 [::]:* users:(("redis_exporter",pid=3995,fd=3))
root@monitor-1:/data/monitor/prometheus cat prometheus.yml
#- job_name: 'mysql'
# static_configs:
# - targets: ['x.x.x.x:9104']
# labels:
# instance: db1
... 略
# MySQL数据库相关
- job_name: 'Redis数据库'
static_configs:
file_sd_configs:
- refresh_interval: 30s
files:
- "vhosts/redis/*.json"
root@monitor-1:/data/monitor/prometheus# cat vhosts/mysql/saas.json
[
{
"targets": ["2.2.2.2:9121"],
"labels": {
"label": "xxxx使用",
"account": "account@xxx.com",
"cloud": "xxxxx",
"instance": "1.1.1.1:6379" # Redis不在本地,覆盖 instance
}
}
]
- Prometheus 命令热加载, 我这里端口: 8090