google / cadvisor

Analyzes resource usage and performance characteristics of running containers.
Other
16.98k stars 2.31k forks source link

Request to update documentation #1834

Open sundeep-paulraj opened 6 years ago

sundeep-paulraj commented 6 years ago

Hi Team,

I am trying to understand the details of how cadvisor is fetching container metrics from the ecosystem and how its identifying when a new container is created etc. Can someone please direct me to the documentation link if its available.

If such info is not available can i request for some assistance in updating the documentation. I would be glad to provide any support needed towards that.

dashpole commented 6 years ago

We could definitely add an architecture doc. At its core, cAdvisor watches for changes in the cgroup tree using a filesystem notifier (currently inotify).

Once a file addition is discovered, the path to the new cgroup is passed to each container handler that is registerd.

Each container handler knows how to identify a container based on the cgroup path. Docker, for example, extracts the docker id from the cgroup path, and queries the docker client for that docker id to see if that cgroup is a docker container.

Many metrics are extracted from cgroups, including memory, cpu, diskio, network, and more. We use the opencontainers/runc/libcontainer library to extract these metrics from cgroups.

Other metrics, such as disk, inodes, and GPU metrics are collected separately from cgroups by using runtime-specific knowledge, such as where the container's writable layer exists on disk.

Each container's metrics are collected at a roughly 10s interval. Historical data for each container is contained in memory, and supplies these metrics for all APIs and storage sinks.

cAdvisor has two json APIs (v1 at api/v1.3, and v2 at api/v2,0, and a prometheus endpoint at metrics. cAdvisor also has a number of storage sinks

sundeep-paulraj commented 6 years ago

thanks a lot David @dashpole , Now this has really helped me to understand the background . your help is much appreciated.