• 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,并导入

  • 相关阅读:
    Js前端路由管理器函数
    js前端登录js脚本
    docker部署certbot与nginx来获取ssl证书添加https及自动更新
    spring boot不同版本的优雅关闭(graceful shutdown)和在windows下winsw服务方式运行的配置
    php下载
    在k8s中导出jvm内存错误dump文件到OSS
    基于alpine构建jdk镜像遇到的坑
    UML建模综述
    Web安全攻防渗透测试实战指南之工具
    数字签名、数字证书是什么?
  • 原文地址:https://www.cnblogs.com/bigberg/p/10119985.html
Copyright © 2020-2023  润新知