Prometheus支持在警报的注释和标签以及服务的控制台页面(如/consoles/index.html.example)中进行模板化。模板具有对本地数据库运行查询,遍历数据,使用条件,格式化数据等功能。Prometheus模板语言基于Go模板系统。
数据结构
处理时间序列数据的主要数据结构是sample,其定义为:
type sample struct {
Labels map[string]string
Value float64
}
sample的指标名称被编码在labels map的特定标签__name__中。
[]sample
表示sample列表。
Go中interface{}
类似于C中的void指针。
功能
除了Go模板提供的默认功能外,Prometheus还提供了一些功能,可简化模板中查询结果的处理。
如果在管道中使用函数,则管道值将作为最后一个参数传递。
Queries
Name | Arguments | Returns</ |
---|