在定义的时间间隔内获取两个指标之间的百分比 [Prometheus]

Get percentage rate between two metrics in a define interval [Prometheus]

我有一个关于普罗米修斯的问题。在我的服务中,我有 2 个计数器,metric_1 是请求总数,metric_2 是失败请求的数量。我需要从中推导出进一步的指标,以确定在定义的时间间隔(例如 2 小时)内请求的错误率百分比。我如何通过 PromQL 等方式实现这一目标?

尝试如下操作:

increase(metric_2[2h]) / increase(metric_1[2h])

increase() function documention

假设metric_1metric_2counters. If these metrics are gauges, then increase() must be substituted by sum_over_time()