美文网首页
Prometheus 监控 Redis

Prometheus 监控 Redis

作者: awker | 来源:发表于2019-06-02 21:30 被阅读0次

    1、下载 redis exporter

    // 下载地址:https://github.com/oliver006/redis_exporter/releases
    # ls redis_exporter-v1.0.0.linux-amd64.tar.gz 
    redis_exporter-v1.0.0.linux-amd64.tar.gz
    # tar xvf redis_exporter-v1.0.0.linux-amd64.tar.gz -C /usr/local/
    

    2、配置 redis_exporter
    2.1 添加账号授权给 redis exporter,以便 redis_exporter 能够连接到 redis server

    2.2 配置 redis_exporter service 文件

    # vim /etc/systemd/system/redis_exporter.service
    [Unit]
    Description=redis_exporter
    After=network.target
    
    [Service]
    Restart=on-failure
    ExecStart=/usr/local/redis_exporter-v1.0.0.linux-amd64/redis_exporter -redis.addr 192.168.22.33:6379 -redis.password 123456
    
    [Install]
    WantedBy=multi-user.target
    
    # systemctl daemon-reload
    # systemctl start redis_exporter
    # systemctl status redis_exporter
    

    -redis.addr 192.168.22.33:6379 -redis.password 123456 --> 配置 redis 连接信息

    3、 查看采集到的数据


    4、添加 prometheus 监控

    # vim prometheus.yml
      - file_sd_configs:
        - files:
          - 'configs/redis.yml'
        job_name: Redis
        metrics_path: /metrics
        relabel_configs:
        - source_labels: [__address__]
          regex: (.*)
          target_label: instance
          replacement: $1
        - source_labels: [__address__]
          regex: (.*)
          target_label: __address__
          replacement: $1:9121
    
    # vim configs/redis.yml
    - labels:
        service: redis_192.168.22.33
      targets:
      - 192.168.22.11
    

    5、 配置 grafana 展示
    https://grafana.com/dashboards/763 下载 json 文件,导入 grafana,根据需求调整即可。

    相关文章

      网友评论

          本文标题:Prometheus 监控 Redis

          本文链接:https://www.haomeiwen.com/subject/sxsfxctx.html