timestamp - 带有时间戳的普罗米修斯指标

标签 timestamp prometheus promql

当我从 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
                ]
            }
        ]
    }
}

但是在图 TableView 中,我可以看到如下图表。这意味着我可以用普罗米修斯的时间戳查询数据。

enter image description here

我想知道如何使用 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"
                    ],
      .........
                ]
            }
        ]
    }
}

关于timestamp - 带有时间戳的普罗米修斯指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56051166/

相关文章:

sql - HH :MM:SS 中的 Oracle SQL 时间差

可变时间范围内的Mysql最大行数

python - 如何从多个子进程公开普罗米修斯指标?

prometheus - 如何通过普罗米修斯查询将二除以计算百分比

prometheus - 如何在普罗米修斯中按两个标签过滤?

javascript - 如何使用 javascript 将时间戳字符串转换为本地时间?

php - 在 $model->find Yii 中使用 UTC_TIMESTAMP()

spring-boot - Spring Boot 2.2.2 - Prometheus 在 Actuator 中不起作用

prometheus - 普罗米修斯中的速率函数是否真的给出了一段时间内的平均值?

prometheus - 处理计算中缺失的指标