visual computation methods
66.3元
包邮
(需用券)
去购买 >
前段时间使用Prometheus,其中的PromQL还是很厉害的查询语法,现在总结下其中的数据查询规则。为了能够帮助用户理解和区分这些不同监控指标之间的差异,Prometheus定义了4种不同的指标类型(metric type):Counter(计数器)、Gauge(仪表盘)、Histogram(直方图)、Summary(摘要)。
返回的样本数据中,其注释中也包含了该样本的类型。例如:
# HELP node_cpu Seconds the cpus spent in each mode.
# TYPE node_cpu counter
node_cpu{cpu="cpu0",mode="idle"} 362812.7890625
Counter:只增不减的计数器
Counter类型的指标其工作方式和计数器一样,只增不减(除非系统发生重置)。常见的监控指标,如http_requests_total,node_cpu都是Counter类型的监控指标。 一般在定义Counter类型指标的名称时推荐使用_total作为后缀。
样记录值:每个时刻对应的总数,因此随着时间增加该值递增或不变。
Counter 的应用
最近10分钟cpu时间增加量:
increase(node_cpu_seconds_total[10m])
最近10分钟cpu的增长率(增量/时间间隔):
rate(node_cpu_seconds_total[10m])
最近10分钟cpu的增长率(该时间段的最后两个值之差/时间间隔):i
irate(node_cpu_seconds_total[10m])
cpu时间排名前10的:
topk(10,node_cpu_seconds_total)
Gauge&#