|NO.Z.00310|——————————|CloudNative|——|KuberNetes&运维.V30|——|监控.v07|PromQL查询_增长率|

一、Prometheus查询增长率:查询增长率:方法一:查询kubelet近1小时访问增长率
### --- 函数:increase()

~~~     表达式:increase(kubelet_http_requests_total{endpoint="https-metrics",instance="192.168.1.11:10250",job="kubelet",long_running="false",method="GET",metrics_path="/metrics",namespace="kube-system",node="k8s-master01",path="metrics",server_type="readwrite",service="kubelet"}[1h])
~~~     输出结果:240.00006722690955        
~~~     注:increase计算的就是这1个小时头和尾它增长了多少个
二、查询增长率:方法一:
### --- 函数:increase()/3600:除以3600秒=增长率

~~~     表达式:increase(kubelet_http_requests_total{endpoint="https-metrics",instance="192.168.1.11:10250",job="kubelet",long_running="false",method="GET",metrics_path="/metrics",namespace="kube-system",node="k8s-master01",path="metrics",server_type="readwrite",service="kubelet"}[1h])/3600
~~~     输出结果:0.06666662931841494
三、rate  查询增长率:方法二:查询kubelet近1小时访问增长率:计算的结果是一样的
### --- 函数:rate()

~~~     表达式:rate(kubelet_http_requests_total{endpoint="https-metrics",instance="192.168.1.11:10250",job="kubelet",long_running="false",method="GET",metrics_path="/metrics",namespace="kube-system",node="k8s-master01",path="metrics",server_type="readwrite",service="kubelet"}[1h])
~~~     输出结果:0.06666664799253556
~~~     # 注:increase和rate:长尾效应:

~~~     它俩取值的时候可能会有个激增,而这个激增可能会影响它的计算结果;可以使用irate来计算
四、irate:查询增长率:方法三:瞬时增长率:查询kubelet近1小时访问增长率
### --- 函数:irate()

~~~     表达式:irate(kubelet_http_requests_total{endpoint="https-metrics",instance="192.168.1.11:10250",job="kubelet",long_running="false",method="GET",metrics_path="/metrics",namespace="kube-system",node="k8s-master01",path="metrics",server_type="readwrite",service="kubelet"}[1h])
~~~     输出结果:0.06665111473989402
~~~     # 注:计算瞬时计算数据:

~~~     取值为1小时的数据,它只取最后2个的数据进行算数,因为最后2个是一样的话,
~~~     它的计算结果会为0;irate会更灵敏;不适合做需要分析长期趋势或者告警规则中使用;
~~~     长期的告警,建议使用rate
五、通过grafana查看rate的增长率
### --- 函数:rate

~~~     表达式:sum(rate(kubelet_runtime_operations_total{cluster="$cluster",job="kubelet", metrics_path="/metrics",instance=~"$instance"}[5m])) by (operation_type, instance)

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(44)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示