|NO.Z.00304|——————————|CloudNative|——|KuberNetes&运维.V24|——|监控.v01|PromQL查询_实例|

一、PromQL基本操作
### --- 通过Prometheus通过自带的WEB-UI来查询

~~~     # 查询方式一:    瞬时向量:包含该时间序列中最新的样本值
~~~     # 查询方式二:    区间向量:带时间戳的:一段时间范围内的数据
### --- 操作符优先级:

~~~     ^ 
~~~     *     /     %
~~~     +    -
~~~     ==    !=    <=    <    >=    >
~~~     And unless    
~~~     or

一、Prometheus查询实例:瞬时向量:查询当前的请求数
### --- 瞬时向量:查询当前的请求数

~~~     # ——>瞬时向量:Enable query history——>http_request_total(查询当前的请求数)
~~~     ——>Execute——>查询出当前https请求的向量:当前最新的向量
~~~     # ——>瞬时向量:
~~~     查看30分钟之前的瞬时向量:值为2         offset 30m  
~~~     # ——>瞬时向量:Enable query history
~~~     ——>http_request_total{endpoint="http",handler="/datasources/proxy/:id/*",instance="172.17.125.18:3000",job="grafana",method="get",namespace="monitoring",pod="grafana-5d9d5f67c4-68kxb",service="grafana",statuscode="502"} offset 30m
~~~     ——>Execute——>这个表达式符合规则的有15个——>当前值为15——>END 
二、区间向量:
### --- 区间向量:

~~~     ——>区间向量:当前值:默认即是1
~~~     ——>Enable query history——>http_request_total{endpoint="http",handler="/",instance="172.17.125.18:3000",job="grafana",method="get",namespace="monitoring",pod="grafana-5d9d5f67c4-68kxb",service="grafana",statuscode="200"}
~~~     ——>Execute——>这个表达式符合规则的就这一个——>当前的值是1
~~~     # ——>区间向量:最近5分钟的向量值:[5m]
~~~     ——>若是需要查看最近5分钟的数据:需要在表达式后面加上——>表达式[5m]——>Execute——>当前的值是5——>是一个时间戳:是可以转换时间的——>END

~~~     # ——>区间向量:1个小时之前5分钟的向量:[5m] offset 1h    
~~~     ——>offset:查看多少分钟之前的数据:offset 30m:30分钟
~~~     ——>表达式[5m]——>后面追加offsete 1h——>Execute

 
 
 
 
 
 
 
 
 

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  阅读(23)  评论(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

导航

统计

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