Prometheus监控 Redis , redis-cli_exporter

自写RedisCLIExporter监控队列长度
在使用Prometheus监控Redis时,发现redis_exporter无法监控队列(list)长度,作者自行用Python编写了一个RedisCLIExporter来解决这一问题。通过连接到指定的Redis实例,该Exporter能够获取并导出队列长度指标。

用Prometheus监控Redis 的时候,发现redis_exporter不能对redis里面的队列(list)长度进行监控,Google了一下,发现官网也没有redis-cli_exporter。
索性就自己用Python写了一个Rediscli_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

转载于:https://blog.51cto.com/13766835/2342040

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值