timestamp - 带有时间戳的 Prometheus 指标
问题描述
当我从 prometheus 查询指标时,我只得到查询时的时间戳。
例如,如果我这样查询数据,
http://localhost:9090/api/v1/query?query=go_memstats_buck_hash_sys_bytes
然后我得到了如下回复。
{
"status": "success",
"data": {
"resultType": "vector",
"result": [
{
"metric": {
"__name__": "go_memstats_buck_hash_sys_bytes",
"instance": "localhost:9090",
"job": "prometheus"
},
"value": [
1557366670.588, <== UNIX time stamp when I queried.
"1472884" <== Value
]
}
]
}
}
但在图表视图中,我可以看到如下图。这意味着我可以使用 prometheus 的时间戳查询数据。
我想知道如何用普罗米修斯的时间戳查询指标。
解决方案
我找到了答案,我需要如下的时间范围。
http://localhost:9090/api/v1/query?query=go_memstats_buck_hash_sys_bytes[5m]
那么结果是,
{
"status": "success",
"data": {
"resultType": "matrix",
"result": [
{
"metric": {
"__name__": "go_memstats_buck_hash_sys_bytes",
"instance": "localhost:9090",
"job": "prometheus"
},
"values": [
[
1557369023.318,
"1491644"
],
[
1557369028.318,
"1491644"
],
[
1557369033.282,
"1491644"
],
.........
]
}
]
}
}
推荐阅读
- ms-office - Microsoft Teams 中是否有 Planning Poker 或类似应用程序
- sql - postgresql 搜索 jsonb 数组项
- c# - 如何将产品信息附加到 xml 序列化程序 dll
- git - 在拉取请求被批准之前,我可以在我的分支中提交吗?
- javascript - Array.prototype.indexOf() 在 React.js 中的工作方式是否不同
- ios - NativeScript-Vue RadList 在 IOS 上无法正常工作
- angular - 升级到 TypeScript 3.1.6(或更高版本)后编译错误
- c++ - 如何在不设置为最大化的情况下最大化尺寸?
- docker - docker 中的 Rust actix_web 无法实现,为什么?
- python - 在Python中清空列表的最快方法是什么