redis_exporter

项目地址:https://github.com/oliver006/redis_exporter

version: 0.x.x

启动步骤

0.x.x版本使用一个exporter监控redis多实例启动方法

1.启动redis_exporter

nohup ./redis_exporter -redis.addr=redis://localhost:6379,redis://localhost:6380 -web.listen-address :50003 &

2.添加prometheus配置(也可添加在自动发现文件中)

  - job_name: 'redis_exporter'
    static_configs:
      - targets:
        - 127.0.0.1:9121

3.重载prometheus配置

curl -X POST http://localhost:9090/-/reload

version 1.x.x

注意事项
  • 1.x版本监控redis多实例启动方式发生了变化,详情参考github中的pr

redis-exporter监控redis多实例_第1张图片

  • 注意添加 -redis.addr,否则会试图连接本地6379端口

image

启动步骤

1.启动redis_exporter

[root@test-125 redis_exporter-v1.3.4.linux-amd64]# nohup ./redis_exporter -redis.addr=  -web.listen-address :50003 &

2.新建json文件

vim /etc/targets-redis-instances.json

[
  {
    "targets": [ "redis://127.0.0.1:6381", "redis://127.0.0.1:6378"],
    "labels": { "redis_env": "TEST" }
  }
]

3.添加prometheus配置

scrape_configs:
  - job_name: 'redis_exporter_targets'
    file_sd_configs:
      - files:
        - targets-redis-instances.json
    metrics_path: /scrape
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9121

  - job_name: 'redis_exporter'
    static_configs:
      - targets:
        - 127.0.0.1:9121

4.重载prometheus配置

curl -X POST http://localhost:9090/-/reload