Grafana Prometheus将$ __间隔设置为1

发布于 2025-02-10 15:05:39 字数 275 浏览 0 评论 0原文

我现在在2s上有$ __ Interval,因为当我尝试将其设置为1时,它将不再显示查询。为什么我能走的2秒?

iRate(rx_bytes {instance =“ localhost:2000”} [2S])工作完美地工作

irate(rx_bytes {instance =“ localhost:localhost:2000”} [1S] [1S]) query> query> query只是消失了

I now have my $__interval on 2s because when I try setting it to 1s it won't display the query anymore. Why is 2s the lowest I can go?

irate(rx_bytes{instance="localhost:2000"}[2s]) works perfectly fine

irate(rx_bytes{instance="localhost:2000"}[1s]) query just disappears

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乙白 2025-02-17 15:05:40

Prometheus在时间戳记 以下面的方式计算irate(m [d]) t :

  1. 它在时间范围上选择原始样本(td .. t] < /代码>针对名称m的每个系列
  2. 。 v1)和(T2,v2)在每个匹配系列的选定时间范围内,其中t1t2是时间戳和 所选时间范围内的最后两个示例的值。
  3. V1V2是 的每个匹配系列。

代码>单独 在您的情况下(又称Scrape_interval)的样本更大或等于1

。继续工作)。 This is a Prometheus-like monitoring solution, which takes into account the previous raw sample just before the selected time range when calculating irate and rate, so it returns the expected result for方括号中的小外观窗户。参见有关详细信息。

ps建议使用rate()而不是irate()在大多数情况下,因为irate()不捕获Spikes-只需基于一组任意的原始样本执行计算即可。参见 row n nofollow noreferrer“> row noreflow noreferrer”>本文有关详细信息。

Prometheus calculates irate(m[d]) at a timestamp t in the following way:

  1. It selects raw samples on a time range (t-d .. t] for each series with the name m. Note that t-d isn't included in the time range.
  2. It finds the last two samples - (t1, v1) and (t2, v2) on the selected time range per each matching series, where t1 and t2 are timestamps and v1 and v2 are values for the last two samples on the selected time range.
  3. It calculates irate=(v2-v1)/(t2-t1) individually per each matching series.

As you can see, Prometheus can calculate irate if the selected time range contains at least two raw samples. Otherwise it returns empty result. So, it is likely the interval between samples in your case (aka scrape_interval) is greater or equal to 1s. So any time range (t-1s .. t] contains less than two samples.

The workaround is to use VictoriaMetrics (the project I work on). This is a Prometheus-like monitoring solution, which takes into account the previous raw sample just before the selected time range when calculating irate and rate, so it returns the expected result for small lookbehind windows in square brackets. See this article for details.

P.S. it is recommended to use rate() instead of irate() in most cases, because irate() doesn't capture spikes - it just performs calculations based on an arbitrary set of raw samples. See this article for details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文