promtheus rate irate sum

作者: admin 分类: prometheus 发布时间: 2017-12-22 16:28 ė 6 没有评论

如果我们以时间窗口来作为筛选纬度计算各个 pool 读IO的真实速率,可以用以下语句查询

irate(ceph_pool_read_total{pool=~"vms"}[1m])

这里的 irate() 为 promethues 的查询函数.与之对应的是rate().

这两个函数在 promethues 中经常用来计算增量或者速率,在使用时需要指定时间范围如[1m]

  • irate(): 计算的是给定时间窗口内的每秒瞬时增加速率.
  • rate(): 计算的是给定时间窗口内的每秒的平均值.
  • 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.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:

    
    
    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.

    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.

如果还是以前面的监控项进行查询但是以 rate() 计算速率的话,绘制的结果如下:

我理解的是rate取的1分钟数据的平均变化率。并非监控数据本身。例如1分钟内 分别增长了50,80 降低了20,因此需要对 (50+80-20)/3  得出即是平均变化率

rate(ceph_pool_read_total{pool=~"vms"}[1m])


sum(node_memory_MemFree) 聚合所有服务器的剩余内存

本文出自 小Q,转载时请注明出处及相应链接。

本文永久链接: http://www.linuxqq.com/archives/1759.html

0
更多
Ɣ回顶部