我使用Prometheus查询将所需的API数据发送到PowerBI。推荐Prometheus链接如下:
https://prometheus.io/docs/prometheus/latest/querying/api/
这里我得到了一个JSON结果,如下所示。有人能帮我弄清楚高亮显示的值是什么吗?(价值1435781451.781)
"value": [ **1435781451.781**, "1" ]似乎是UNIX时间戳。但是那个时间戳是什么?每次执行查询时,它都会发生变化。
我想得到实际的API调用时间戳。
$ curl 'http://localhost:9090/api/v1/query?query=up&time=2015-07-01T20:10:51.781Z'
{
"status" : "success",
"data" : {
"resultType" : "vector",
"result" : [
{
"metric" : {
"__name__" : "up",
"job" : "prometheus",
"instance" : "localhost:9090"
},
"value": [ 1435781451.781, "1" ]
},
{
"metric" : {
"__name__" : "up",
"job" : "node",
"instance" : "localhost:9100"
},
"value" : [ 1435781451.781, "0" ]
}
]
}
}
发布于 2022-10-16 21:28:33
是的,这是一个以秒为单位的Unix时间戳,参见https://prometheus.io/docs/prometheus/latest/querying/api/#instant-vectors。
即时查询的即时向量类型结果中每个样本的时间戳始终等于查询的计算时间戳。评估时间戳是通过time=... HTTP参数显式提供的,或者当省略时,Prometheus服务器选择自己的当前服务器时间作为评估时间戳(参见https://github.com/prometheus/prometheus/blob/76b0d26be84b4f653e42c620a78850ad17b580c9/web/api/v1/api.go#L383)。也许后者就是你要找的?
这两篇博客文章对于更好地理解PromQL查询是如何总体执行的,以及查询中的选择器是如何工作的,也很感兴趣:
https://stackoverflow.com/questions/74057721
复制相似问题