Prometheus監(jiān)控Redis,redis-cli_exporter

用Prometheus監(jiān)控redis 的時(shí)候,發(fā)現(xiàn)redis_exporter不能對(duì)redis里面的隊(duì)列(list)長度進(jìn)行監(jiān)控,Google了一下,發(fā)現(xiàn)官網(wǎng)也沒有redis-cli_exporter。
索性就自己用Python寫了一個(gè)Rediscli_exporter.

莆田ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!

#!/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監(jiān)控 Redis , redis-cli_exporter

網(wǎng)站標(biāo)題:Prometheus監(jiān)控Redis,redis-cli_exporter
本文URL:http://bm7419.com/article6/jjeeig.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、虛擬主機(jī)、網(wǎng)站導(dǎo)航、網(wǎng)站改版、網(wǎng)站建設(shè)、App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)