How to setup Docker container monitoring with Zabbix
In a Docker infrastructure, monitoring the containers is vital to ensure that a single container do not end up abusing the host machine and crash other containers.
Docker container monitoring involves keeping an eye on the metrics such as available CPU, mem, blkio, etc. These metrics for a container can be seen with the command ‘docker stats‘.
But monitoring containers from the backend manually is a time-consuming process and not feasible for pro-active management of machines.
This makes it important to have a monitoring system setup for the Docker containers.
Docker container monitoring with Zabbix
We setup a custom Zabbix server for our internal system monitoring purposes. Zabbix is an open source monitoring software for network and applications.
Zabbix consists of a server running in a container and agents running on the machines that need to be monitored. The machine data are stored in a database.
To install Zabbix server in a Docker container, create a container using the ‘docker-zabbix’ image:
docker run -d -P --name zabbix berngp/docker-zabbix
To monitor Docker containers using Zabbix, a Zabbix agent has to be installed in the Docker machine. Zabbix agent is an application that tracks the metrics of systems being monitored.
We added our Docker infrastructure to that monitoring system with these steps:
1. Create Zabbix Agent container
The first step is to create a container with Zabbix agent image, specifying the Zabbix server IP, with this command:
docker run \ --name=zabbix-agent-xxl \ -h $(hostname) \ -p 10050:10050 \ -v /:/rootfs \ -v /var/run:/var/run \ -e "ZA_Server=<ZABBIX SERVER IP/DNS NAME>" \ -d monitoringartist/zabbix-agent-xxl-limited:latest
You can see the newly created Zabbix Agent container running in the Docker machine, with the ‘docker ps’ command:
2. Configure the Zabbix Agent
The configuration file for the Zabbix Agent is available at ‘/etc/zabbix/zabbix_agentd.conf’. This file contains details such as Zabbix server and other parameters.
In the Zabbix server, add the hosts (containers to be monitored) and the triggers for them. This can be done easily with the help of Zabbix templates.
The container metrics for CPU, I/O, memory, disk usage, etc. can be retrieved from their containers’ cgroup stats folders and monitored using Zabbix.
To test the Zabbix agent, the utility ‘zabbix_agent_bench’, the bench-marking tool, can be used.
[ Running a Docker infrastructure doesn’t have to be hard, or costly. Get world class Docker management services at affordable pricing. ]
Bobcares provides Outsourced Hosting Support and Outsourced Server Management for online businesses. Our services include Hosting Support Services, server support, help desk support, live chat support and phone support.