Prometheus相关库文档:
https://prometheus.io/docs/instrumenting/clientlibs/
python示例
Counter
Counters go up, and reset when the process restarts.
from prometheus_client import Counter
c = Counter('my_failures', 'Description of counter')
c.inc() # Increment by 1
c.inc(1.6) # Increment by given value
counter指标类型只能增加,重启时置零,可以使用计数器来表示所服务的请求数,已完成的任务或错误。
Gauge
Gauges can go up and down.
from prometheus_client import Gauge
g = Gauge('my_inprogress_requests', 'Description of gauge')
g.inc() # Increment by 1
g.dec(10) # Decrement by given value
g.set(4.2) # Set to a given value
Gauge指标类型表示单个数值,可以任意地上升和下降的度量。通常用于测量值,如温度或当前内存使用情况。
Gauge指标不能使用rate,irate等增长率统计表达式
设置 Labels
#Taking a counte