Prometheus 速率函数如何计算结果?

Prometheus 速率函数如何计算结果?,prometheus,Prometheus,我看到这个关于利率的问题 我不明白考试的结果 rate(counter[2s]): will get the average from the increment in 2 sec and distribute it among the seconds So in the first 2 second we got an increment of total 3 which means the average is 1.5/sec. final result: second result 1

我看到这个关于利率的问题

我不明白考试的结果

rate(counter[2s]): will get the average from the increment in 2 sec and distribute it among the seconds
So in the first 2 second we got an increment of total 3 which means the average is 1.5/sec. final result:

second result
1       1,5
2       1,5
3        2
4        2
5       3,5
6       3,5
7       3,5
8       3,5
9       4,5
10      4,5


你能给我解释一下逻辑吗?

我想问题中的OP只是算错了。这个问题的答案非常清楚和详细地解释了它,提供了使用的确切公式。还举了一个例子(在评论中):

如果
t1
为1,
t5
为5;而
t1
处的值为1,
t5
处的值为10(如上所述),则
(v5-v1)/(t5-t1)
(10-1)/(5-1)
,即
2.25

这显然与原始示例第5秒时的速率(计数器[5s])相矛盾,即2。还请注意,在回答中,第1节的ICH应为0

现在,我将尝试手动计算:

rate(counter[5s]): (v_y - v_x) / (t_y - t_x)

second result     calculation
1       N/A     (1 - 1) / (1 - 1)
2        2      (3 - 1) / (2 - 1)
3       2.5     (6 - 1) / (3 - 1)
4        2      (7 - 1) / (4 - 1)
5       2.25    (10 - 1) / (5 - 1)
6       2.75    (14 - 3) / (6 - 2)
7       2.75    (17 - 6) / (7 - 3)
8       3.5     (21 - 7) / (8 - 4)
9       3.75    (25 - 10) / (9 - 5)
10      4       (30 - 14) / (10 - 6)

rate(counter[5s]): will get the average from the increment in 5 sec and distribute it among the seconds
The same as for [2s] but we calculate the average from total increment of 5sec. final result:

second result
1        2
2        2
3        2
4        2
5        2
6        4
7        4
8        4
9        4
rate(counter[5s]): (v_y - v_x) / (t_y - t_x)

second result     calculation
1       N/A     (1 - 1) / (1 - 1)
2        2      (3 - 1) / (2 - 1)
3       2.5     (6 - 1) / (3 - 1)
4        2      (7 - 1) / (4 - 1)
5       2.25    (10 - 1) / (5 - 1)
6       2.75    (14 - 3) / (6 - 2)
7       2.75    (17 - 6) / (7 - 3)
8       3.5     (21 - 7) / (8 - 4)
9       3.75    (25 - 10) / (9 - 5)
10      4       (30 - 14) / (10 - 6)