You need to enable JavaScript to run this app.
文档中心
托管 Prometheus

托管 Prometheus

复制全文
下载 pdf
PromQL 入门
PromQL 选择器
复制全文
下载 pdf
PromQL 选择器
您可以通过 PromQL 中的标签,对数据进行筛选,本文为您介绍标签的使用方法。​
标签选择器​
Prometheus 中的原始数据中包含多个标签,很多时候,我们需要只查看指定标签的内容。此时,需要使用标签选择器。​
标签选择器使用 {} 来标记,例如:查询 http 状态码为 400 的请求数量。​
​
http_requests_total{code="400"}​
​
在标签选择器中,可以使用匹配运算符来选择标签,支持的选择运算符包括:​
  • =:与字符串匹配​
  • !=:与字符串不匹配​
  • =~:与字符串正则匹配​
  • !~:与字符串正则不匹配​
范围选择器​
范围选择器常用来指定一段时间。例如:查询 http 状态码为 400 ,过去 5 分钟的采样记录。​
​
http_requests_total{code="400"}[5m]​
​
在范围选择器中,可以指定不同的时间。​
​
时间单位​
说明​
s​
秒​
m​
分钟​
h​
小时​
d​
天​
w​
周​
y​
年​
​
​
最近更新时间:2025.02.20 15:57:51
这个页面对您有帮助吗?
有用
有用
无用
无用