当前位置:   article > 正文

prometheus监控redis、redis_cluster集群_prommetheus监控redis

prommetheus监控redis

1.1 安装下载redis_exporter

下载地址:
https://github.com/oliver006/redis_exporter/releases

tar -xvf  redis_exporter-v1.55.0.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv redis_exporter-v1.55.0.linux-amd64/ redis_exporter
  • 1
  • 2
  • 3

1.2 启动

cd /usr/local/redis_exporter
nohup ./redis_exporter -redis.addr 172.20.2.18:6379 &    
nohup ./redis_exporter -redis.addr 172.20.2.18:6380 &   

多实例(有密码)
cd /usr/local/redis_exporter
nohup ./redis_exporter -redis.addr 172.2.1.3:6380 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9120 &
nohup ./redis_exporter -redis.addr 172.2.1.3:6381 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9121 &
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

1.3 配置systemctl并加入开机自启(此步骤可省略)

1.3.1 redis无密码版
cat > /etc/systemd/system/redis_exporter.service << "EOF"
[Unit]
Description=redis_exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target
 
[Service]
ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 172.22.201.32:6380
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
1.3.2 redis有密码版
cat > /etc/systemd/system/redis_exporter.service << "EOF"
[Unit]
Description=redis_exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target
 
[Service]
ExecStart=/usr/local/bin/redis_exporter -redis.addr 172.22.201.32:6380 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9120
ExecStart=/usr/local/bin/redis_exporter -redis.addr 172.22.201.32:6381 --redis.password=oj+xjlARRfJqbC+A --web.listen-address=:9121
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
systemctl daemon-reload
systemctl enable redis_exporter
systemctl start redis_exporter
systemctl status redis_exporter
  • 1
  • 2
  • 3
  • 4

在这里插入图片描述

3.4配置prometheus

vim prometheus.yaml
#监控redis_cluster集群
  - job_name: 'redis_exporter_cluster'
    static_configs:
      - targets:
        - redis://172.22.1.4:6380
        - redis://172.22.1.4:6381
    params:
      check-keys: ["metrics:*"]
    metrics_path: /scrape
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 172.22.15.84:9121
  #监控redis
  - job_name: 'redis_exporter'
    static_configs:
      - targets:
        - 172.22.15.84:9121
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

ps:replacement:redis_exporter所在机器的ip+端口

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/624696
推荐阅读
相关标签
  

闽ICP备14008679号