将指标push到pushgateway
使用push 方式把数据推送到pushgateway。
# cat client.py #!/usr/bin/python3 from prometheus_client import CollectorRegistry, Gauge, push_to_gateway registry = CollectorRegistry() g = Gauge('ping', '检测最大响应时间',['dst_ip','city'], registry=registry) #Guage(metric_name,HELP,labels_name,registry=registry) g.labels('192.168.1.10','shenzhen').set(42.2) #set设定值 g.labels('192.168.1.11','shenzhen').dec(2) #dec递减2 g.labels('192.168.1.12','shenzhen').inc() #inc递增,默认增1 push_to_gateway('localhost:9091', job='ping_status', registry=registry)
https://www.cnblogs.com/xiaobaozi-95/p/10684524.html
posted on 2022-04-07 16:19 MissSimple 阅读(163) 评论(0) 编辑 收藏 举报