• 欢迎来到小爱博客,一个分享互联网IT技术的网站,喜欢就收藏吧!

prometheus redis监控

prometheus 小爱 2个月前 (08-29) 33次浏览 已收录 0个评论 扫描二维码
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

推荐看板:


小爱博客 , 版权所有
转载请注明原文链接:prometheus redis监控
喜欢 (1)
【你的支持, 我的动力】
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址