Select Page

How to setup Docker container monitoring with Zabbix

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‘.

Docker container metrics

Docker container metrics

But monitoring containers from the backend manually is a time-consuming process and not feasible for pro-active management of machines.

Save your Docker containers from crash

GET IN TOUCH WITH THE DOCKER EXPERTS NOW!

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:

 

Create Zabbix Docker container

Create Zabbix Docker container

 

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.

 

Benchmarking the Zabbix agent

Benchmarking the Zabbix agent

[ Running a Docker infrastructure doesn’t have to be hard, or costly. Get world class Docker management services at affordable pricing. ]


Secure your Docker images!

Wish you had more time to focus on your business? Let us help you.

Our engineers will assist you to setup, monitor and manage your Docker infrastructure 24/7.

GET IN TOUCH WITH THE EXPERTS NOW!




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.

2 Comments

  1. Thank you for your artcile.

    “Zabbix consists of a server running in a container” – is it a necessary requirement for Zabbix server to be installed inside a container?

    Actually, our Zabbix server is installed just as an ordinary VM. We would like to monitor our Docker containers without any modifications regarding to Zabbix server itself.

    Thank you!

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares
Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.
MORE ABOUT BOBCARES