Google cAdvisor

Google cAdvisor allows to easily analyze resource usage and performance characteristics of running containers. This stand-alone container provides real-time dashboards for all the running containers and exports metrics as default.

The Google cAdvisor is a lightweight container which provides resource and usage information for containers running on Docker hosts. cAdvisor provides a nice real-time Dashboard UI to visualize performance and also provides metrics to send to monitoring tools.

Welcome back to this episode of The Byte. In this episode, we're gonna talk about cAdvsior, Google cAdvsior or container advisor. Now for those that don't know, cAdvsior is a real-time monitoring container. It's a deployed standalone. You can integrate it with different tools like Prometheus, InfluxDB, elastic search, Kafka, Redis, StatsD. It has a lot of different storage drivers and availabilities, and what's really cool is it exports its metrics by default.
So once you start the container, you jump in, you can see a real-time dashboard. Let me just look at the dashboard quickly. My setup when I'm running it locally on my Mac, it's port 8080. And then it brings me to the cAdvsior dashboard, that now shows me every container running on my host.

Now it's quite nice. I can see the CPU's. If I have reservation limits for these containers, also for the memory, it gives me like nice dials as you see in the car for like RPM for the CPU, memory, file system usage, for the different file systems.

Then I can see some real time graphs as I start scrolling down. So the CPU, I can see total usage, users by core, users breakdown. As I keep scrolling down the UI, I can see memory, the network, and it allows me actually to see each network interface. So both virtual and physical networks or a complete total network.

As I keep scrolling down and I can see the file system usage. So I can see my overlays, I can see shared memory, cgroups, and finally, I can see top CPU usage by container, I can see top memory usage by container.
Now I only have one container running at the moment on my machine, but I can quickly jump in and see, dive down into for example the cAdvsior container and it shows me statistics just for the cAdvsior. And that's really handy when you want to do some troubleshooting.

Now I use cAdvsior for my monitoring stacks because it's very nice UI and what's really nice, as I mentioned before, the URL is port 8080, and if I go /metrics, it exposes the metrics automatically. So it's in already in Prometheus metrics format and all I need to do is then point my Prometheus server at cAdvsior and it starts scraping these metrics. And that's really helpful and it's an easy win if you want to start monitoring something quite easily.

So what happens is I recommend running a cAdvsior at every host that you're running because the cAdvsior quickly looks at every running container on that host. It basically does statistics and it's able to provide information on all the running containers.

Then you take Prometheus, you grab this and you're able to basically summarize all the information per host and get like a global view of all your hosts. And it's one command to get it up and running. It's a doc, a run command.

Now just so you know, it requires slightly more permission than a normal container because we need access to the root file system, we need access to sys, dev for specific devices, et cetera. So you do need to run it as Sudu in some cases because it needs access to these different file systems to be able to reach these containers.

Now what's interesting is Google uses this quite heavily. I mean if you look on Dr. Hub, you can see it already has over 10 million pulls. And I remember talking to the developer about this quite some time ago and he said that they were using it quite heavily internally for their projects and it's quite up to date.

They have some canary built as well. The documentation is quite good. I mean it's something that can be easily run. I mean I run it quite often, both on my laptop as well as in production.

Because it's so easy to get up and running, it's easy to visualize, and it's also very good for people just getting started to visualize what's happening with their containers.

Because you just run this next to your container and it provides all this information in a nice dashboard. Again, it integrates to the different data sources. The web UI is very straightforward.

And I'll drop the links of cAdvisor into the show notes, so, and also on Docker Hub and you can take a look at how easy it is to get up and running.

That's it for this episode. Google cAdvisor. If you have time, have a look. Drop me a line if you have any questions or what your particular use case is and I'll talk about it next episode.
Have a great day.
Brian Christner