我有一个像这样的文件
# HELP process_cpu_user_seconds_total Total user CPU time spent in seconds.
# TYPE process_cpu_user_seconds_total counter
process_cpu_user_seconds_total{NODE_APP_INSTANCE="undefined",instance="127.0.0.1:9091",job="my_server"} 3.938 1689042066
# HELP process_cpu_system_seconds_total Total system CPU time spent in seconds.
# TYPE process_cpu_system_seconds_total counter
process_cpu_system_seconds_total{NODE_APP_INSTANCE="undefined",instance="127.0.0.1:9091",job="my_server"} 0.593 1689042066
# HELP nodejs_gc_duration_seconds Garbage collection duration by kind, one of major, minor, incremental or weaken.
# TYPE nodejs_gc_duration_seconds histogram
nodejs_gc_duration_seconds_bucket{le="0.001",kind="minor",NODE_APP_INSTANCE="undefined",instance="127.0.0.1:9091",job="my_server"} 8 1689042066
# EOF
我将promtool tsdb create-blocks-from openmetrics ./the.prom ./data
这些指标推送到 tsdb,
结果是
BLOCK ULID MIN TIME MAX TIME DURATION NUM SAMPLES NUM CHUNKS NUM SERIES SIZE
01H51E3HM7YJ90DJ72THJ20QX2 1689042066000 1689042066001 1ms 3 3 3 1419
我将数据复制到 prometheus 数据中。我可以用它promtool tsdb dump
查看我的指标是否在 tsdb 文件中
{NODE_APP_INSTANCE="undefined", __name__="nodejs_gc_duration_seconds_bucket", instance="localhost:9091", job="my_server", kind="minor", le="0.001"} 8 1689042066000
{NODE_APP_INSTANCE="undefined", __name__="process_cpu_system_seconds_total", instance="localhost:9091", job="my_server"} 0.593 1689042066000
{NODE_APP_INSTANCE="undefined", __name__="process_cpu_user_seconds_total", instance="localhost:9091", job="my_server"} 3.938 1689042066000
答案1
我认为您没有让 UI 运行正确的查询。
您加载的数据仅跨越1ms
,prometheus UI 上的默认分辨率和范围Graph
不适合这种情况。您无法在Table
任何一个下看到它,因为度量标准始终是过去的。
Evaluation time
您应该在prometheus 上指定样本的时间戳Table
,这将有助于 UI 进行正确的查询:
curl 'http://$PROEMTHEUS/api/v1/query?query=nodejs_gc_duration_seconds_bucket&time=1689042066'
(如果上述查询未返回任何内容,您可能需要等待/让 prometheus 考虑新的块)
如果你加载跨度较长时间的数据,你应该可以在 prometheus 上轻松看到它们Graph
。