首页   快速返回

rate与irate的区别     所属分类 prometheus
计算某个指标在一定时间范围内的变化速率

irate 取指定时间范围内的最近两个数据点计算速率,
rate取指定时间范围内所有数据点,取平均值作为结果。

irate适合快速变化的计数器 counter,rate适合缓慢变化的计数器 counter

对于快速变化的计数器,如果使用rate,因为使用平均值,会把峰值削平。

分别用 irate 和 rate 来监控CPU使用率指标


sum(irate(process_cpu_seconds_total[10m])) * 100

sum(rate(process_cpu_seconds_total[10m])) * 100

rate 曲线 比 irate 平缓


irate  calculates the per-second instant rate of increase of the time series in the range vector. 
This is based on the last two data points. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for.

irate计算距离向量中时间序列每秒的瞬时增长率。
基于最后两个数据点。单调中断后会自动调整(目标重启计数器重置)


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:

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, as brief changes in the rate can reset the FOR clause and graphs consisting entirely of rare spikes are hard to read.


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.


当 irate 与 聚合操作(例如sum )或 时间聚合函数(任何以_over_time结尾的函数)组合在一起时,总是首先使用irate(),然后聚合。
否则,当目标重新启动时,irate()无法检测计数器重置。


rate(v range-vector) calculates the per-second average rate of increase of the time series in the range vector. 
Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. 
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.

计算外推到时间范围的末端,允许没有抓取的数据 或 抓取周期与范围的时间周期不完全对齐。

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

上一篇     下一篇
linux性能监控工具sysstat介绍

vim颜色及行号设置

prometheus job 和 instance

prometheus要点整理

grafana使用模板变量

dubbo架构及调用模型