gpt4 book ai didi

kubernetes - container_memory_rss 与使用的节点内存的关系

转载 作者:行者123 更新时间:2023-12-04 13:26:28 28 4
gpt4 key购买 nike

我试图理解关于 的 container_memory_rss 或 container_memory_working_set_bytes node_memory_used 即(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes)
这是我的意思
PROMQL 1:

sum(container_memory_rss) by (instance) / 1024 / 1024 / 1024

{instance="172.19.51.8:10250"} 7.537441253662109
PROMQL 2:
sum(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) by (instance) / 1024 / 1024 / 1024

{instance="172.19.51.8:9100"} 2.2688369750976562
PROMQL 3:
sum(container_memory_working_set_bytes) by (instance) / 1024 / 1024 / 1024

{instance="172.19.51.8:10250"} 9.285114288330078
PROMQL 4:
sum(node_memory_MemAvailable_bytes) by (instance) / 1024 / 1024 / 1024

{instance="172.19.51.8:9100"} 13.356605529785156
因此,如果 Pod 始终在 Node.js 上运行。我不明白为什么是 container_memory_rss container_memory_working_set_bytes 超过 node_memory_used
即 PROMQL 1 和 PROMQL 3 的值远远超过 PROMSQL 2 的值,即节点使用的内存。
我不知道我是否正确,pod/容器 rss 不应该总是 <= 使用的节点内存(即使没有设置默认资源限制)

最佳答案

tl;博士
使用容器名称过滤器排除总计:

# you may have a different label for container name
sum(container_memory_rss{name!=""}) by (instance) / 2^30
解释
如果您按容器名称运行第一个查询分组结果,您会注意到大部分用法来自没有名称的容器:
sort_desc(sum(container_memory_rss{instance="ip-192-168-104-46"}) by (name)) / 2^30

{} 3.9971389770507812
{name="prometheus"} 0.6084518432617188
{name="cluster-autoscaler"} 0.04230499267578125
实际上有几个没有名字的条目,但它们都有一个 id :
sort_desc(sum(container_memory_rss{instance="ip-192-168-104-46"}) by (id)) / 2^30

# these do not have a container name
{id="/"} 1.1889266967773438
{id="/kubepods"} 0.900482177734375
{id="/kubepods/burstable"} 0.6727218627929688
{id="/system.slice/docker.service"} 0.07495498657226562
{id="/system.slice/kubelet.service"} 0.060611724853515625

# and this is an example id of a real container which has a name label
{id="/kubepods/burstable/pod562495f9-afa6-427e-8435-016c2b500c74/e73975d90b66772e2e17ab14c473a2d058c0b9ffecc505739ee1a94032728a78"} 0.6027107238769531
这些是每个 cgroup 的累积值. cAdvisorcgroups 获取统计信息如果你看它们,你会发现熟悉的实体:
# systemd-cgls -a
├─kubepods
│ ├─podc7dfcc4e-74fc-4469-ad56-c13fe5a9e7d8
│ │ ├─61a1a58e47968e7595f3458a6ded74f9088789a865bda2be431b8c8b07da1c6e
│ │ └─d47601e38a96076dd6e0205f57b0c365d4473cb6051eb0f0e995afb31143279b
│ ├─podfde9b8ca-ce80-4467-ba05-03f02a14d569
│ │ ├─9d3783df65085d54028e2303ccb2e143fecddfb85d7df4467996e82691892176
│ │ └─47702b7977bed65ddc86de92475be8f93b50b06ae8bd99bae9710f0b6f63d8f6
│ ├─burstable
│ │ ├─pod9ff634a5-fd2a-42e2-be27-7e1028e96b67
│ │ │ ├─5fa225aad10bdc1be372859697f53d5517ad28c565c6f1536501543a071cdefc
│ │ │ └─27402fed2e4bb650a6fc41ba073f9994a3fc24782ee366fb8b93a6fd939ba4d3
如果你总结了所有的直接 child ,比如 kubepods ,您将获得相同的值 kubepods已。由于这些总数 sum(container_memory_rss) by (instance)显示了实际资源利用率的数倍。
解决方案只是过滤掉没有容器名称的任何值。您可以在查询时执行此操作,如顶部示例所示,也可以使用 relabel_config 配置 Prometheus。在抓取时删除此类指标。

关于kubernetes - container_memory_rss 与使用的节点内存的关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68220372/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com