1. cd /opt
    2. https://github.com/oliver006/redis_exporter/releases/download/v1.18.0/redis_exporter-v1.18.0.linux-amd64.tar.gz
    3. tar xvf redis_exporter-v1.18.0.linux-amd64.tar.gz
    4. ln -s redis_exporter-v1.18.0.linux-amd64 redis_exporter

    因这里是测试环境,redis没有加密码,如有密码,启动参数加上-redis.password=xxxxxx

    vim /usr/lib/systemd/system/redis_exporter.service 
    [Unit]
    Description=redis_exporter
    Documentation=
    After=network.target
    
    [Service]
    Type=simple
    WorkingDirectory=/opt/redis_exporter
    ExecStart=/opt/redis_exporter/redis_exporter -redis.addr 192.168.0.15:6379
    ExecStop=/bin/kill -KILL 
    ExecReload=/bin/kill -HUP 
    KillMode=control-group
    Restart=on-failure
    RestartSec=3s
    StartLimitInterval=30s
    StartLimitBurst=5
    
    [Install]
    WantedBy=multi-user.target
    

    prometheus.yml新增job

      - job_name: redis_exporter
        file_sd_configs:
          - files: ['/opt/prometheus/targets/redis_sd_configs/*.json']
            refresh_interval: 5s
    

    添加target

    cat /opt/prometheus/targets/redis_sd_configs/redis.json 
    [{
            "labels": {
                    "ip": "192.168.0.15",
                    "hostname": "test-wk",
                    "env": "test"
            },
            "targets": ["192.168.0.15:9121"]
    }]
    

    granfa添加图形模板
    ID:731
    image.png