【问题标题】:Using rate instead of sum/count in micrometer使用速率而不是微米的总和/计数
【发布时间】:2020-11-20 03:27:12
【问题描述】:

在这个link,它说明了必须将速率用于微米度量的原因。

Representing a counter without rate normalization over some time window is rarely useful, as the representation is a function of both the rapidity with which the counter is incremented and the longevity of the service.

我仍然无法理解为什么不直接求和/计数。

任何输入都是有帮助的。

【问题讨论】:

    标签: prometheus micrometer


    【解决方案1】:

    您希望在 Prometheus 查询中使用 rate() 函数的原因是,您可以查看该时间窗口内的平均速率(该文档示例中的 [10s])。

    如果您使用的是总和/计数,则该数字将继续增长,并且平均值不会涵盖最新的时间范围,而是自服务启动以来所有时间的平均值。

    例子:

    假设您有一个计时,每次调用它需要 1 秒,并且每分钟大约调用 30 次:

                       Count        Sum        sum/count   sum/count (with increase)
    First Minute:      30           30         1           1
    After 10 hour:     18,000       18,000     1           1
    After 1000 hours:  1,800,000    1,800,000  1           1
    

    到目前为止,它看起来是一样的。现在假设在最后 1 分钟内所有请求都需要 10 秒。这是慢 10 倍。你会想知道最后一分钟的事

                       Count        Sum        sum/count   sum/count (with increase)
    First Minute:      30           300        10          10
    After 10 hour:     18,000       18,270     1.015       10
    After 1000 hours:  1,800,000    1,800,270  1.00015     10
    

    rate(或increase)函数确保它只是使用该窗口中的更改进行计算。由于该指标运行时间较长,因此较大的数字掩盖了任何波动。

    注意:在我的示例中,我使用了increase 函数,因为它更容易推理。它只是报告该窗口中计数器或总和增加了多少。 rate 类似,但只是将其标准化为每秒速率。

    【讨论】:

      猜你喜欢
      • 2021-11-11
      • 1970-01-01
      • 2014-07-03
      • 2018-10-30
      • 2015-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-22
      相关资源
      最近更新 更多