标签:rate export site list password usr text 没有 exp
用Prometheus监控Redis 的时候,发现redis_exporter不能对redis里面的队列(list)长度进行监控,Google了一下,发现官网也没有redis-cli_exporter。#!/usr/bin/env python
#coding:utf-8
#Author: shuaibing.huo@gmail.com
import prometheus_client
import redis
from prometheus_client import Gauge
from flask import Response,Flask
app = Flask(__name__)
queue_len = Gauge("www_site_queue_len","the len of redis_queue")
@app.route("/metrics")
def redis_conn():
pool = redis.ConnectionPool(host="xxxxxxxx.redis.rds.aliyuncs.com",port=6379,db=0,password="avavavav")
conn = redis.Redis(connection_pool=pool)
queue_len_data = conn.llen("www_site")
queue_len.set(queue_len_data)
return Response(prometheus_client.generate_latest(queue_len),mimetype="text/plain")
if __name__ == "__main__":
app.run(host="0.0.0.0",port=9101)
Prometheus监控 Redis , redis-cli_exporter
标签:rate export site list password usr text 没有 exp
原文地址:http://blog.51cto.com/13766835/2342040