Prometheus 计算 delta 并忽略一个标签

Yan*_*lem 2 prometheus

首先是一些数据说明:

指标名称:query_seconds_count

示例值:

query_seconds_count{correlation_id="someUUID",instance="someIp:Port",job="someJob",query_type="query",segment="overall"}
Run Code Online (Sandbox Code Playgroud)

我想做的事:

delta(query_seconds_count[1m])
Run Code Online (Sandbox Code Playgroud)

问题:

每个查询的标签correlation_id都是唯一的,因此没有机会找到匹配的相关 ID 来计算增量。因此 Delta 始终为 0。有没有办法correlation_id在计算 Delta 时忽略标签?

我读到了有关关键字的信息ignoringwithoutby它们似乎不适用于 delta 函数。

可能的解决方法

我可以使用它来解决 delta 函数,但这看起来不太优雅。

sum(query_seconds_count) without (correlation_id) - sum(query_seconds_count offset 1m) without (correlation_id)
Run Code Online (Sandbox Code Playgroud)

bri*_*zil 5

标签correlation_id对于每个查询都是唯一的,因此没有机会找到匹配的相关id来计算增量。

这就是事件日志记录,普罗米修斯根本不适合它,因为这不是一个指标。对于此类数据,您需要使用 ELK 等系统。如果您想使用Prometheus,则需要删除客户端代码中的相关ID。

此外,切勿delta在计数器上使用该功能。你可能想要increase