Monitoring LXC containers is not much different than monitoring a VM or a server - we can run a monitoring client inside the container, or on the actual host that runs LXC. Since the root filesystem of the containers is exposed on the host and LXC uses cgroups and namespaces, we can collect various information directly from the host OS, if we would rather not run a monitoring agent in the container. Before we look at two examples of LXC monitoring, let's first see how we can gather various metrics that we can monitor and alert on.
LXC provides a few simple tools that can be used to monitor the state of the container and its resource utilization. The information they provide, as you are going to see next, is not that verbose; however, we can utilize the cgroup filesystem and collect even more information from it. Let's explore each of these options.