There are two ways to monitor containers. One is to use the command line of orchestration platforms, such as Docker or Kubernetes, to access logs and information about the containers. This gives you a basic overview, and you can use the logs to analyze possible causes of errors. However, the main drawback is that manual monitoring is inefficient and time-consuming, and it's easy to lose track. In addition, this method does not provide alerts when problems occur.
The second option is to use a monitoring solution that is designed specifically for container monitoring and that provides all the necessary visibility into container resource usage along with features such as historical data analysis, data visualization, and alerting.
The Docker command line includes some commands that you can use for container monitoring:
docker stats [OPTIONS] [CONTAINER...] command displays real-time resource usage statistics for all running containers, providing insight into CPU, memory usage, memory limit, and network IO metrics. If you wish to focus on specific container(s), you can specify a list of container names or IDs separated by spaces.
- You can view the running container list using the
docker ps [OPTIONS]. Use the
-all command to show all containers.
- You can use the
docker top CONTAINER [ps OPTIONS] command to view the processes for a specific container.
Alternatively, Docker containers can be monitored with a monitoring solution. The benefits of dedicated container monitoring software include:
- Detailed information about the performance and resource usage of Docker nodes and containers. For example, CPU utilization, memory usage, and disk I/O.
- Visualization of key metrics in dashboards.
- Contextual information for effective root cause analysis and complex problem-solving.
- Storage of historical data to analyze trends or changes in the Docker topology.
- Alerts on critical events or anomalies in the container environment.
For example, Checkmk uses an agent to obtain detailed information about the Docker node and every single container.
Kubernetes provides the ability to monitor containers through the metrics server. This makes it possible to retrieve a limited set of metrics, such as CPU and memory utilization, via the Kubernetes Metrics API. With the Kubernetes Dashboard, the container platform also offers a web-based user interface that provides a convenient way to manage and monitor the containerized applications in a Kubernetes cluster once deployed.
It allows users to deploy and troubleshoot applications, as well as manage cluster resources. Kubernetes Dashboard provides an overview of all running applications in the cluster and allows users to create and modify Kubernetes resources such as deployments, jobs, and daemon sets. In addition, the Kubernetes Dashboard enables actions such as scaling a deployment, initiating a rolling update, restarting a pod, or deploying new applications. It also provides visibility into a cluster's resources and errors that have occurred.
Kubernetes Dashboard also stores historical data, although more limited in quantity and scope than a monitoring solution like Checkmk. Dedicated Kubernetes monitoring software, such as Checkmk, can provide more comprehensive monitoring capabilities.
Checkmk uses the API server to get basic information about the cluster. The Checkmk Node Collector and the Checkmk Cluster Collector, which provides information about how much memory a DaemonSet is currently consuming, provide a comprehensive picture.
Checkmk monitors the clusters, nodes, deployments, pods, DaemonSets, and StatefulSets of a Kubernetes environment, providing key metrics such as CPU, memory, file systems, disk I/O, kernel performance, and threads. Kubernetes monitoring with Checkmk also provides intelligent alerting and a wealth of contextual information for troubleshooting.