prometheus - rate函数如何计算结果?
问题描述
我在 rate 上看到了这个问题 我是否正确理解 Prometheus 的 rate vs increase 函数?
second counter_value increase calculated by hand(call it ICH from now)
1 1 1
2 3 2
3 6 3
4 7 1
5 10 3
6 14 4
7 17 3
8 21 4
9 25 4
10 30 5
我不明白的结果
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
和
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
你能解释一下逻辑吗?
解决方案
我认为问题中的 OP 只是计算错误。该问题的唯一答案非常清楚和详细地解释了它,并提供了要使用的确切公式。还有一个例子(在评论中):
如果
t1
是 1 并且t5
是 5;处的值为t1
1,处的值为t5
10(如上),(v5 - v1) / (t5 - t1)
则为(10 - 1) / (5 - 1)
,即2.25
这显然与rate(counter[5s])
第 5 秒的原始示例相矛盾,即 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)
推荐阅读
- python - 如何打印文本,使其看起来像是正在输入的?
- arrays - 这个算法叫什么名字?
- azure - 如何克隆 Azure 中的内置计划定义策略?
- python - 在 django (pytest) 中使用权限测试登录保护页面
- linker - 使用 ld 链接包含 stdio 函数的目标文件,未找到 crt0.o
- r - 如何在 Windows 下测试 socketConnection?
- opencv - 深度 CNN 不学习,准确率保持不变
- python - ImportError:无法导入名称 UART
- r - 将 chr 转换为数字 apply() 以从应用函数更新数字列
- wpf - WPF Listview ModelView 只更新一次