|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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了