简体   繁体   English

Prometheus 监控 Kubernetes 容器内存使用情况并报告容器使用情况是否超过 90%

[英]Prometheus monitoring Kubernetes Container Memory usage and report if container using more than 90%

Looking for example how to monitor Container Memory Usage with Prometheus.寻找如何使用 Prometheus 监控容器内存使用情况的示例。

It reports all the containers ok if we using this query:如果我们使用这个查询,它会报告所有容器正常:

(container_memory_usage_bytes / container_spec_memory_limit_bytes) * 100 > 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.除数为 0,结果为 +Inf,这意味着警报触发错误,因为 +Inf 匹配 > 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.我已经解决了添加另一个标签has_memory_limit ,我用它来仅对定义了限制的容器发出警报。


Okay, I have figured it out:好的,我已经想通了:

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

Since positive infinity, negative infinity and NaN are numbers in Prometheus , you can simply filter them out with != +Inf .由于正无穷大、负无穷大和 NaN 是Prometheus中的数字,您可以简单地使用!= +Inf它们过滤掉。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kubernetes Prometheus:当容器内存使用量大于 kube 节点总内存容量时添加警报 - Kubernetes Prometheus: Add alert when container memory usage is greater than total kube node memory capacity 使用 Prometheus 监控 Kubernetes 持久卷的使用情况 - Monitoring Kubernetes persistent volumes usage with Prometheus 使用 AWS Container Insights 监控 Kubernetes CronJob 完成情况 - Monitoring Kubernetes CronJob completion using AWS Container Insights 使用 Jmeter - Kubernetes 进行测试后,spring boot 的容器内存使用率不低 - Container memory usage with spring boot not low after testing with Jmeter - Kubernetes Kubernetes Pod 报告的内存使用量比实际进程消耗量多 - Kubernetes Pod reporting more memory usage than actual process consumption 如何使用普罗米修斯作为监控来计算kube.netes中容器的cpu使用率? - How to calculate containers' cpu usage in kubernetes with prometheus as monitoring? GKE 容器被“Memory cgroup out of memory”杀死,但监控、本地测试和 pprof 显示使用量远低于限制 - GKE container killed by 'Memory cgroup out of memory' but monitoring, local testing and pprof shows usage far below limit 普罗米修斯与kubernetes上的多容器豆荚 - Prometheus with multi-container pod on kubernetes Openshift PaaS / Kubernetes Docker容器监控和编排 - Openshift PaaS/Kubernetes Docker Container Monitoring and Orchestration 使用更多 memory 然后容器 itslef 处理 - Process using more memory then container itslef
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM