【问题标题】:Incorrect reporting of container memory usage by cadvisorcadvisor 错误报告容器内存使用情况
【发布时间】:2018-03-22 11:57:21
【问题描述】:

cAdvisor 报告 Prometheus 使用的内存为 14GB,而 top 报告为 6.xGB。

有人可以解释为什么会出现这种差异吗?

container_memory_usage_bytes 的文档说

Current memory usage in bytes, including all memory regardless of when it was accessed

但不清楚这是指什么 - 我假设它是虚拟内存大小?

据 cAdvisor 报告:

core@ip-172-20-100-148 ~ $ curl -q localhost:4194/metrics | grep container_memory_usage_bytes | grep prometheus
container_memory_usage_bytes{container_name="prometheus",id="/docker/d37e7503309e632265cb834095efa949da4dc3c72122cb290e626f1121d0ed6b",image="quay.io/prometheus/prometheus:v1.7.1",name="k8s_prometheus.71f5f8c6_prometheus-zwvhx_xx-system_9753de21-aaac-11e7-97e5-026a05f72f78_4682ea0b",namespace="xx-system",pod_name="prometheus-zwvhx"} 1.4178545664e+10

根据主机上的 top 报告:

Tasks: 272 total,   1 running, 271 sleeping,   0 stopped,   0 zombie
%Cpu(s): 20.2 us,  2.7 sy,  0.0 ni, 75.9 id,  0.5 wa,  0.6 hi,  0.1 si,  0.0 st
KiB Mem:  65964640 total, 64892592 used,  1072048 free,  5222520 buffers
KiB Swap:        0 total,        0 used,        0 free.  4737420 cached Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                   
118446 root      20   0 6783108 6.154g  19864 S 316.7  9.8   8241:05 prometheus 

【问题讨论】:

  • 是的,你是对的,VIRT 包括 RES。我在回答中犯了这个简单的错误。你的容器里会不会有另一个进程?

标签: kubernetes prometheus cadvisor


【解决方案1】:

根据here 的讨论,cAdvisor 报告了total 内存使用量(以字节为单位)。

在您的情况下,cAdvisor 报告了1.4178545664e+10 Byte = 14.178545664 Gigabyte。请注意,它是e+10,所以它大约是 14G,而不是 1.4G。

【讨论】:

  • 我认为 VIRT 包括 RES - 它没有?而且,我对 Prometheus 报告的内存进行了更正,我在帖子中对其进行了编辑。
猜你喜欢
  • 2015-02-27
  • 2015-07-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-28
  • 1970-01-01
  • 2019-11-20
相关资源
最近更新 更多