Collectd将实际主机系统度量标准推送到石墨,而不是docker工具容器的受限系统度量标准

我有一个内存限制为300M和CPU-1内核的Docker容器。 当容器启动并执行程序时,它将内存限制限制为300M,并将CPU固定到第一个CPU内核。

然而,在容器内运行的collectd会推动实际盒子( 16 GB RAM )的内存和交换内存的度量,而不是受限制的容器(300 MB RAM)。

有没有我错过的configuration?

Docker运行命令:

docker run -e CONTAINER_NAME='sample_docker_container' -m 300M --memory-swap=300M --cpuset-cpus="1" --net=host --name=sample_docker -p 4000:4000 -p 4001:4001 -p 4002:4002 sample_docker 

石墨指标:

收集Container的指标

从图中可以看出,这些指标正在被推向> 300MB的RAM。 当我在我的实际框中运行高性能代码(使用超过4 GB的RAM)时,容器内的collectd也会使用RAM。

所以它不是从Docker容器内部收集和推送度量。

collectd.conf:

 Hostname sample_docker_container Interval 60 LoadPlugin logfile <Plugin logfile> LogLevel info File STDOUT Timestamp true PrintSeverity false </Plugin> Include "/opt/comp/indis-docker/collectd/conf/collectd.d/*" 

collectd_perf.conf:

 LoadPlugin disk LoadPlugin load LoadPlugin memory LoadPlugin swap LoadPlugin vmem LoadPlugin interface <Plugin interface> Interface "lo" Interface "eth0" Interface "eth1" IgnoreSelected false </Plugin> LoadPlugin df <Plugin df> MountPoint "/dev" MountPoint "/run" MountPoint "/run/lock" MountPoint "/run/shm" IgnoreSelected true ValuesPercentage true </Plugin> LoadPlugin cpu LoadPlugin "aggregation" <Plugin "aggregation"> <Aggregation> Plugin "cpu" Type "cpu" SetPlugin "cpu" SetPluginInstance "%{aggregation}" GroupBy "Host" GroupBy "TypeInstance" CalculateMinimum true CalculateMaximum true CalculateAverage true </Aggregation> </Plugin> LoadPlugin "match_regex" PostCacheChain "Cpumetrics" <Chain "Cpumetrics"> <Rule> <Match "regex"> Plugin "^cpu$" PluginInstance "^[0-9]+$" </Match> <Target write> Plugin "aggregation" </Target> Target stop </Rule> Target "write" </Chain>