Collectd pushes the actual host system metrics to graphite instead of the docker container's restricted system metrics

て烟熏妆下的殇ゞ 提交于 2019-12-11 13:00:52

问题


I've a docker container deployed with a memory restriction of 300M and CPU-1 Core. When the container starts and my program executes, it is adhering the memory restriction to 300M and CPU to 1st CPU Core.

However the collectd running inside the container pushes the metrics of Memory and Swap memory of the actual box (16 GB RAM) instead of the restricted containers (300MB RAM).

Is there any configuration that I'm missing?

Docker run command:

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

Graphite metrics:

As seen in the graph, the metrics are being pushed for > 300MB of RAM. When I run a high performance code (which uses more than > 4 GB RAM) in my actual box then the collectd from within the container is also spiking up the RAM used.

So its not collecting and pushing metrics from inside docker container.

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>

来源:https://stackoverflow.com/questions/37881322/collectd-pushes-the-actual-host-system-metrics-to-graphite-instead-of-the-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!