![](/img/trans.png)
[英]What is the difference between “container_memory_working_set_bytes” and “container_memory_rss” metric on the container
[英]PromQL difference between memory usage and working set
我正在尝试确定一段时间内容器的平均使用量 memory
下面是我在 OpenShift 4.9 中使用的查询
sum by (namespace, pod) (avg_over_time(pod:container_memory_usage_bytes:sum[2d]))
上面的查询在 4.11 版本的 OpenShift 中不起作用,所以我尝试修改上面的查询
sum by (namespace, pod) (avg_over_time(node_namespace_pod_container:container_memory_working_set_bytes{}[2h])/1048576)
两个查询都提供不同的值,但有细微差别。
我对使用上述 2 中的哪个查询来确定 POD 使用的平均 memory 感到困惑。
PromQL 中memory usage和working set的区别在于,memory usage 是指分配给进程的 memory 的总量,而 working set 是进程正在使用的 memory 的总量。 Memory usage 包括active 和 inactive memory ,而 working set 只包括正在被 active使用的 memory。 换句话说,工作集是 memory 用法的一个子集。
以下表达式可用于汇总两天内命名空间和 pod 的平均 pod 容器 memory 使用情况:
sum by (namespace, pod) (avg_over_time(pod:container_memory_usage_bytes:sum[2d]))
建议使用以下查询,因为 memory_working_set 将给出 memory 的使用情况,该地址已被积极使用。
sum by (namespace, pod) (avg_over_time(node_namespace_pod_container:container_memory_working_set_bytes{}[2h])/1048576)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.