• Prometheus Redis_exporter


    Redis

    下载redis_exporter

    wget https://github.com/oliver006/redis_exporter/releases/download/v0.15.0/redis_exporter-v0.15.0.linux-amd64.tar.gz
    
    tar -zxvf redis_exporter-v0.15.0.linux-amd64.tar.gz -C /usr/local/redis_exporter

    编写启动脚本

    cd /usr/local/redis_exporte
    ln -s redis_exporter /usr/sbin/redis-exporter
    mkdir bin
    cd bin
    vim redis-exporter.sh
    
    #!/bin/bash
    
    basedir=$(cd `dirname $0`/..; pwd)
    redis_host=localhost
    redis_port=6379
    redis_password=abc123
    
    RETVAL=0
    PROG="redis-exporter"
    EXEC="/usr/sbin/redis-exporter"
    LOCKFILE="/var/lock/subsys/$PROG"
    OPTIONS="-redis.addr $redis_host:$redis_port -redis.password $redis_password"
    
    # Source function library.
    if [ -f /etc/rc.d/init.d/functions ]; then
      . /etc/rc.d/init.d/functions
    else
      echo "/etc/rc.d/init.d/functions is not exists"
      exit 0
    fi
    
    start() {
      if [ -f $LOCKFILE ]
      then
        echo "$PROG is already running!"
      else
        echo -n "Starting $PROG: "
        nohup $EXEC $OPTIONS >/dev/null 2>&1 &
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch $LOCKFILE && success || failure
        echo
        return $RETVAL
      fi
    }
    
    stop() {
      echo -n "Stopping $PROG: "
      killproc $EXEC
      RETVAL=$?
      [ $RETVAL -eq 0 ] && rm -r $LOCKFILE && success || failure
      echo
    }
    
    restart ()
    {
      stop
      sleep 1
      start
    }
    
    case "$1" in
      start)
        start
        ;;
      stop)
        stop
        ;;
      status)
        status $PROG
        ;;
      restart)
        restart
        ;;
      *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
    esac
    exit $RETVAL

    如果redis没有密码,就不需要-redis.password

    启动脚本并验证

    ./redis-exporter.sh start
    
    curl localhost:9121/metrics

    加入Prometheus

    编辑prometheus.yml文件,添加内容
    
        - job_name: 'redis'
            static_configs:
            - targets: ['172.16.10.62:9121']
    
    重启prometheus

    Grafana Dashboard

    搜索redis的grafana dashboard,并导入

  • 相关阅读:
    jQuery实现 自动滚屏操作
    jQuery实现全选、全不选以及反选操作
    读曾国藩
    把时间当作朋友 之感知时间
    把时间当作朋友4未知永远存在
    Android N 设置中语言列表介绍
    如何编译ICU资源
    idea常用快捷键
    shell 笔记
    Json笔记
  • 原文地址:https://www.cnblogs.com/bigberg/p/10119985.html
Copyright © 2020-2023  润新知