接以上prometheus二次开发之HTTP api(一):/weixin_44723434/article/details/104282636
最近做监控方案发现可能用到的http api接口还有元数据查询相关,故新增相关接口介绍:
查询元数据
1.按标签查询匹配
URL地址:
GET /api/v1/series
POST /api/v1/series
URL查询参数:
- match[]=<series_selector>:必填,标签选择器。
- start=<rfc3339 | unix_timestamp>*启动时间戳。
- end=<rfc3339 | unix_timestamp>*结束时间戳。
返回结果的data部分由匹配到的标签名称/值对的对象列表组成。
以下示例返回与选择器up或匹配的所有系列 process_start_time_seconds{job=“prometheus”}。
$ curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=up' --data-urlencode 'match[]=process_start_time_seconds{job="prometheus"}'
{
"status" : "success",
"data" : [
{
"__name__" : "up",
"job" : "prometheus",
"instance" : "localhost:9090"
},
{
"__name__" : "up",
"job" : "node",
"instance" : "localhost:9091"
},
{
"__name__" : "process_start_time_seconds",
"job" : "prometheus",
"instance" : "localhost:9090"
}
]
}