python采集信息到prometheus

采集脚本

# coding=utf-8

from prometheus_client import Gauge, start_http_server
import requests
import time

jvsn = Gauge('zhibiao1', '描述', ['app_name', 'app_user'])
tes = Gauge('zhibiao2', '描述', ['app_name', 'app_user'])

if __name__ == '__main__':
    start_http_server(1234)
    while True:
        jvsn.labels(app_name=app_name, app_user=app_user).set('指标1')
        tes.labels(app_name=app_name, app_user=app_user).set('指标2')
        time.sleep(60*5)

使用supervisor维护

维护

[program:prometheus_main]
directory=/home/project/bigdata-script/python/flinkJob
command=python3 prometheus_main.py
autostart=true
autorestart=false
stderr_logfile=/tmp/prometheus_main.log
stdout_logfile=/tmp/prometheus_main.log
user=root
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10

你可能感兴趣的:(python,python)