redis_exporter 地址:
https://github.com/oliver006/redis_exporter
下载redis_exporter
wget https://github.com/oliver006/redis_exporter/releases/download/v1.0.1/redis_exporter-v1.0.1.linux-amd64.tar.gz
tar xvf redis_exporter-v1.0.1.linux-amd64.tar.gz
systemd启动
cat > /etc/systemd/system/redis_exporter.service <<EOF
[Unit]
Description=redis_exporter
Documentation=https://github.com/oliver006/redis_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 127.0.0.1:6379
#ExecStart=/usr/local/redis_exporter -redis.addr 10.31.121.90:6379 -redis.password 123456
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
如redis设置密码 -redis.password string
启动
systemctl start redis_exporter
systemctl enable redis_exporter
测试 URL 获取 metrics
curl http://ip:9121/metrics
Basic Prometheus Configuration
Add a block to the scrape_configs of your prometheus.yml config file:
scrape_configs:
- job_name: redis_exporter
static_configs:
- targets: ['<<REDIS-EXPORTER-HOSTNAME>>:9121']
Prometheus Configuration to Scrape Multiple Redis Hosts
scrape_configs:
## config for the multiple Redis targets that the exporter will scrape
- job_name: 'redis_exporter_targets'
static_configs:
- targets:
- redis://first-redis-host:6379
- redis://second-redis-host:6379
- redis://second-redis-host:6380
- redis://second-redis-host:6381
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: <<REDIS-EXPORTER-HOSTNAME>>:9121
## config for scraping the exporter itself
- job_name: 'redis_exporter'
static_configs:
- targets:
- <<REDIS-EXPORTER-HOSTNAME>>:9121
推荐看板: