prometheus类型

Counter:只增。

# 查找过去1分钟增长量
sum(increase(prometheus_http_request_count{}[1m]))

 Gauge:可增可减。

# 查找瞬时值
sum(prometheus_http_request_gauge{})

Histograms:样本落在桶中,原子统计数量,后面一个bucket包含前面所有bucket计数。

# 查找过去5分钟的90%分位耗时
histogram_quantile(0.9, rate(prometheus_http_request_duration_seconds_bucket{}[5m]))

Summaries:存储分位数,例如95%样本耗时最大值,通过全局锁+排序获取百分位对应下标,损耗性能,一般不用。

带标签的类型
NewCounter -> NewCounterVec
NewGauge -> NewGaugeVec
NewHistogram -> NewHistogramVec
NewSummary -> NewSummaryVec

posted on 2024-03-29 19:58  王景迁  阅读(38)  评论(0)    收藏  举报

导航