Bobcares

How to setup Docker container monitoring with Zabbix

by | Nov 3, 2016

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

3. Checking the Zabbix Agent logs

Once the Zabbix Agent starts running in the machine, you can check the logs related to it using ‘docker logs’ command. This is usually relevant for trouble-shooting purposes.

 

Check Zabbix container logs

Check Zabbix container logs

 

4. Monitoring the Docker containers

Once the Zabbix service starts working fine, you can view reports on the Docker container performance with Zabbix graphs. CPU, memory, disk space, I/O, etc. are monitored.

 

Zabbix monitoring graph for Docker containers

Zabbix monitoring graph for Docker containers

 

By monitoring the Docker containers, it is possible to identify the containers that are taking up more resources and to limit the usage based on their plans.

Read our post on ‘How to improve Docker performance with resource control using cgroups‘, to know more about what to do next, based on monitoring results.

[ Are your spending too much time managing your Docker containers? Our Docker experts take care of your infrastructure and ensure its smooth functioning. ]

To summarize..

Today we saw how to implement Docker container monitoring with the help of Zabbix. Being open source, it is possible to customize the Zabbix based on business requirements.

After setting up the monitoring system, more vital part is 24/7 proactive monitoring of the containers to avoid a crash or resource shortage.

At Bobcares, our 24/7 expert engineers monitor and maintain the Docker container resources in an optimal way to ensure the best performance.

If you’d like to know how to manage your Docker system and to get the best out of them for your business, we’d be happy to talk to you.

 

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!

var google_conversion_label = "owonCMyG5nEQ0aD71QM";


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.

3 Comments

  1. Alexey

    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 *

Never again lose customers to poor
server speed! Let us help you.