如何获得CPU使用率高于X%的时间百分比?

发布于 2025-02-09 04:38:12 字数 281 浏览 1 评论 0原文

我有一个查询以获取百分比的CPU使用情况:

avg without (mode,cpu) (
  1 - rate(node_cpu_seconds_total{mode="idle", job="openwrt"}[1m])
) *100

我想获得以上CPU使用的时间百分比,例如80%。

因此,例如,如果数据为56.4 32.5 53.5 89.0 67.9 21.2 90.4 25.7 6.7 6.7 92.3是3/10 = 30%

I have this as a query to get CPU usage in percentage:

avg without (mode,cpu) (
  1 - rate(node_cpu_seconds_total{mode="idle", job="openwrt"}[1m])
) *100

I want to get the percentage of time that the CPU usage is above, for example, 80%.

So for example if the data is 56.4 32.5 53.5 89.0 67.9 21.2 90.4 25.7 6.7 92.3 it'll be 3/10 = 30%

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

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

发布评论

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

评论(1

乖乖哒 2025-02-16 04:38:12

尝试以下查询:

avg_over_time((
  avg without (mode,cpu) (
    1 - rate(node_cpu_seconds_total{mode="idle", job="openwrt"}[1m])
  ) * 100 >bool 80
)[1h:1m]) * 100

此查询返回CPU SAGE在最后一个小时高出80%的时间百分比。它使用 subquery feature 用于计算 avg_over_time 在最后一个小时的每时平均CPU使用率上。

Try the following query:

avg_over_time((
  avg without (mode,cpu) (
    1 - rate(node_cpu_seconds_total{mode="idle", job="openwrt"}[1m])
  ) * 100 >bool 80
)[1h:1m]) * 100

This query returns the percentage of time when CPU sage was higher than 80% during the last hour. It uses subquery feature for calculating avg_over_time over the per-minute average CPU usage for the last hour.

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