简体   繁体   中英

sum of rate function in prometheus

Given the following prometheus time series called requests : 在此处输入图像描述

the vector query requests[3 seconds] is:
在此处输入图像描述

and the rate of the vector query requests[3 seconds], rate(requests[3 sec]) (computed by the shown formula) is:

在此处输入图像描述

My question is: what is sum(rate(requests[3 sec])) evaluated at seconds 5, 4 and 3 respectively is it 16.5, 6.5 and 1. Any idea?

You are misunderstanding the purpose of sum. It is not performing a sum over time but over the dimensions of your metric.

In your example, assuming there are multiple requests metrics (with a dimension page by exemple), rate(requests[3 sec]) will give you (at some point in time):

{page="A"}  12.4
{page="B"}  1.5
{page="C"}  0 .... (and so on for each metrics requests with different label set)

The sum function will sum the values of the different rates; and sum(ate(requests[3 sec])) will give you only one value:

{}  42.13 <-- the sum of all rate(requests[3s]) values

BONUS: In the case you metric have multiple dimensions (represented by multiple labels in your metric) you can tell sum() to operate on a subset of them: sum(rate(requests[3 sec])) ON(foo)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM