google / cadvisor

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

Expose host port numbers used by container(s) #2121

Open iyesin opened 5 years ago

iyesin commented 5 years ago

Hello,

Thanks for creating this nice product. I am using cAdvisor in AWS environment a lot. Currently I'm running it in ECS environment as sidecar container. It was working fine for all metrics that I was expected to find except one: ports, exposed by containers, started by ECS.

Container with cAdvisor starting like that:

docker run -d --name cadvisor -p 30303:8080 -v /var/lib/docker/:/var/lib/docker:ro -v /:/rootfs:ro -v /var/run:/var/run:rw -v /var/log:/var/log:ro -v /cgroup:/cgroup:ro -v /sys:/sys:ro -v /:/rootfs:ro -v /cgroup:/sys/fs/cgroup:ro google/cadvisor:v0.31.0 -logtostderr -disable_metrics udp,sched
dashpole commented 5 years ago

With a few exceptions (image name and labels, for example), cAdvisor is scoped to collecting metrics that can be observed through cgroups and linux proc files. It does not generally provide information about the specification of docker containers, such as volumes, ports, env variables, IP, etc.

iyesin commented 5 years ago

@dashpole things you are saying is really contrasting with command-line options I observing for cAdvisor. Say --docker-prefixed option set says that cAdvisor can talk with docker daemon via the socket to retrieve container-related data (like env. variables, storage parameters and etc.). Furthermore, to get environment variables and container labels cAdvisor should call /containers/<container id or name>/json endpoint anyway. By calling this endpoint cAdvisor will receive this data anyway, so why not expose more data from there? (sorry for typos and editing)

dashpole commented 5 years ago

Oh, it does have env variables. My mistake. We interact with a number of different container runtimes, not just docker. We would need to find the equivalent information for each container runtime if we want to consider adding this.