本节重点介绍 : prometheus 四种查询类型
- 4种查询类型
- vector
- matrix
- scalar
- string
- instant query 对应vector
- range query 对应matrix
prometheus四种查询类型
- 文档地址
- 查询类型源码地址 D:\nyy_work\go_path\src\github.com\prometheus\prometheus\promql\parser\value.go
即时向量 Instant vector
: 一组时间序列,每个时间序列包含一个样本,所有样本共享相同的时间戳
- vector 向量 源码位置 D:\nyy_work\go_path\src\github.com\prometheus\prometheus\promql\value.go
- vector 向量,是samples的别名,但是所有sample具有相同timestamp ,常用作instant_query的结果
- 在prometheus页面上就是table查询 ,对应查询接口 /api/v1/query
- 举例图片
范围向量 Range vector
: 一组时间序列,一段时间的结果
- 在prometheus页面上就是graph查询 ,对应查询接口 /api/v1/query_range
- 返回的结果是Matrix 矩阵,源码位置 D:\nyy_work\go_path\src\github.com\prometheus\prometheus\promql\value.go
- Matrix是series的切片 Series源码位置 D:\nyy_work\go_path\src\github.com\prometheus\prometheus\promql\value.go
- series 是标签组+Points的组合
- 举例图片
标量 Scalar
一个简单的数字浮点值
- 举例图片
String 一个简单的字符串值;目前未使用
本节重点总结 : prometheus 四种查询类型
- 4种查询类型
- vector 一个时刻的结果
- matrix 一段时间的结果
- scalar 浮点数
- string
- instant query 对应vector
- range query 对应matrix