码迷,mamicode.com
首页 > 其他好文 > 详细

Prometheus Querying Function rate() vs irate()

时间:2018-04-27 19:37:59      阅读:1958      评论:0      收藏:0      [点我收藏+]

标签:改变   一个   follow   适合   mis   agg   you   计算   family   

rate()

rate(v range-vector) calculates the per-second average rate of increase of the time series in the range vector.

rate()函数计算某个时间序列范围内的每秒平均增长率

 

Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for.

自适应单调性中断(比如target重启导致的计数器重置)。

 

Also, the calculation extrapolates to the ends of the time range, allowing for missed scrapes or imperfect alignment of scrape cycles with the range‘s time period.

计算结果是推算到每个时间范围的最后而得出,允许漏抓和抓取周期与时间范围的不完美结合。

 

The following example expression returns the per-second rate of HTTP requests as measured over the last 5 minutes, per time series in the range vector:

以下示例返回最后五分钟HTTP请求每秒增长率

rate(http_requests_total{job="api-server"}[5m])

rate should only be used with counters. It is best suited for alerting, and for graphing of slow-moving counters.

rate应该只和计数器一起使用。最适合告警和缓慢计数器的绘图。

Note that when combining rate() with an aggregation operator (e.g. sum()) or a function aggregating over time (any function ending in _over_time), always take a rate() first, then aggregate. Otherwise rate() cannot detect counter resets when your target restarts.

irate()

irate(v range-vector) calculates the per-second instant rate of increase of the time series in the range vector.

irate()函数计算一段时间范围内某个时刻的每秒增长率

 

This is based on the last two data points. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for.

基于最后两个数据点进行计算。自适应单调性中断(比如target重启导致的计数器重置)。

 

The following example expression returns the per-second rate of HTTP requests looking up to 5 minutes back for the two most recent data points, per time series in the range vector:

以下示例返回五分钟内最近两次数据点的HTTP请求每秒增长率

irate(http_requests_total{job="api-server"}[5m])

irate should only be used when graphing volatile, fast-moving counters. Use rate for alerts and slow-moving counters,

rate应该只和快速的、不稳定的计数器一起使用。

 

as brief changes in the rate can reset the FOR clause and graphs consisting entirely of rare spikes are hard to read.

因为比率短暂的改变可以充值FOR语句,而且一个包含极少的峰(突然上升)的图是很难阅读的。

Note that when combining irate() with an aggregation operator (e.g. sum()) or a function aggregating over time (any function ending in _over_time), always take a irate() first, then aggregate.

Otherwise irate() cannot detect counter resets when your target restarts.

Prometheus Querying Function rate() vs irate()

标签:改变   一个   follow   适合   mis   agg   you   计算   family   

原文地址:https://www.cnblogs.com/jugglee/p/8963743.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!