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.yml文件,添加内容 - job_name: 'redis' static_configs: - targets: ['172.16.10.62:9121'] 重启prometheus