Prometheus监视Kubernetes容器内存使用情况并报告容器使用率是否超过90% [英] Prometheus monitoring Kubernetes Container Memory usage and report if container using more than 90%

查看:76
本文介绍了Prometheus监视Kubernetes容器内存使用情况并报告容器使用率是否超过90%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如何通过Prometheus监视容器内存使用情况.

Looking for example how to monitor Container Memory Usage with Prometheus.

如果使用此查询,它将报告所有容器正常:

It reports all the containers ok if we using this query:

(container_memory_usage_bytes / container_spec_memory_limit_bytes) * 100 > 90

但是,如果容器没有定义内存限制,则可以正常工作.除数为0,结果为+ Inf,这意味着由于+ Inf匹配>90.

However works ok if container does not have a memory limit defined. The the divisor is 0, and the results are +Inf, meaning that the alert triggers incorrectly since +Inf matches > 90.

关于如何正确使用容器内存使用情况监视的任何建议?

Any suggestions how to properly use Container Memory Usage monitoring?

推荐答案

几天前,我从不同的角度提出了相同的问题

I asked the same question from a different perspective just a few days earlier here. So far I have not found an answer. I have settled with adding another label has_memory_limit that I use to only alert on containers that have a limit defined.

好的,我知道了:

((container_memory_usage_bytes / container_spec_memory_limit_bytes) != +Inf)  * 100 > 52

由于正无穷大,负无穷大和NaN是 Prometheus ,您只需使用!= + Inf 即可将其过滤掉.

Since positive infinity, negative infinity and NaN are numbers in Prometheus, you can simply filter them out with != +Inf.

这篇关于Prometheus监视Kubernetes容器内存使用情况并报告容器使用率是否超过90%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆