Install Zabbix On Docker

/ Comments off

Special Offer

  1. Install Zabbix In Docker
  2. Install Zabbix Proxy Docker
  3. Install Zabbix Docker Ubuntu
  4. Install Zabbix Agent On Docker Container

I couldn't figure out a way to get the create.sql.gz file to install while running inside a Docker CentOS 7 container (even though I can start it with systemd running properly), but I did the following workaround.

  • Mar 27, 2020 That's the Docker Compose file I use. The difference here is that I use web frontend container instead of using host's Apache. On host Nginx I do proxy to the frontend.
  • Step 5 – Configure Zabbix Frontend. – Make sure that all software prerequisites are met. – Enter details for connecting to the database. Zabbix database must already be created. – Enter Zabbix server details. – Review a summary of settings. – Finish the installation. – Now you’ll be redirected to the zabbix web console page.

Zabbix Monitoring Course Discount $11.99
https://www.udemy.com/course/zabbix-monitoring/?couponCode=607976806882D016D221
Offer expires in hours. Be quick and share with your friends and colleagues.

Special Offer

Grafana Course Discount $13.99
https://www.udemy.com/course/grafana-tutorial/?couponCode=D04B41D2EF297CC83032
Offer expires in hours. Be quick and share with your friends and colleagues.

Special Offer

Prometheus Course Discount $9.99
https://www.udemy.com/course/prometheus/?couponCode=EB3123B9535131F1237F
Offer expires in hours. Be quick and share with your friends and colleagues.

Special Offer

Threejs Course Discount $9.99
https://www.udemy.com/course/threejs-tutorials/?couponCode=416F66CD4614B1E0FD02
Offer expires in hours. Be quick and share with your friends and colleagues.

Video Lecture

Description

I choose to install Zabbix Server from packages.

The download page is at

I have the Install from Packages tab active,

I then choose Zabbix 5.0, Ubuntu, 20.04 Focal and MySQL for the database.

It is important to download the correct version for your operating system. To check, type hostnamectl

Ubuntu 20.04

After the update, you can confirm your APT (Advanced Packaging Tool) references the correct versions.

Note

You don't have to use Ubuntu 20.04, MySQL and Apache, but most of the examples in this course use them, so it will be much easier for you to follow. If it works in my video, but not for you on Centos, it is likely to be SELINUX or a default firewall setting.

Centos 8

After the update, you can confirm your DNF (Dandified YUM (Yellow Dog Updater)) references the correct versions.

Zabbix 5.0

Ubuntu 20.04 Focal

Ubuntu 18.04 Bionic

Ubuntu 16.04 Xenial

Centos 8

Centos 7

Zabbix 4.4

Ubuntu 20.04 Focal

Zabbix

Ubuntu 18.04 Bionic

Ubuntu 16.04 Xenial

Centos 8

Centos 7

Zabbix distributes Docker images for each component. Not only does this mean you can quickly standup the monitoring solution, but upgrades also become a simple matter of trading up images.

In this article, I will show how to stand up and then upgrade a zabbix installation using docker-compose.

Prerequisite

If you don’t already have Docker and Docker Compose installed, then see my article here for installing on Ubuntu.

Also make sure you have a git client

Checkout an older 4.0.1 version

Although Zabbix has newer 4.2 images, we will start by standing up a 4.01 image so that we can later show the upgrade path to 4.0.13 and then the latest 4.2.

Deploy a 4.0.1 stack

Then deploy the full stack described in the yml using docker-compose:

After a few minutes of pulling down the images and creating the containers, it is done. You should see multiple zabbix related containers now when you run:

The status of each should show as “up”. And if you want to follow the tailed logs of all the components:

Validate the 4.0.1 stack

In order to validate, we need to know the IP address of the nginx container that is exposing the Zabbix Admin web interface, which can be done using:

The “zabbix-docker_zbx_net_frontend” used to pull the outside facing IP address is created by Docker Compose, and is the concatenation of the directory name “zabbix-docker” and “zbx_net_frontend” defined in the networks section of the original yaml.

The web front end should be available via HTTP on port 80, which means commands like below should be successful (substitute with your IP from above).

And from the browser, you should be able to login with the default credentials (Admin/zabbix).

This will get you into the Zabbix Admin web interface.

If you scroll to the very bottom of that web page the version will be shown as “Zabbix 4.0.1”.

Enable Zabbix Agent reporting

You may notice that the dashboard lists one problem ‘Zabbix agent on Zabbix server is unreachable for 5 minutes’. This is because unlike a standard installation where they would be processes on the same host, the zabbix agent is in a different container than the server.

To fix, this we need to get the IP address of the zabbix agent which is on the backend network.

Go back to the Zabbix Admin web interface, and go to Configuration > Hosts, and click on the “Zabbix server” to update to the IP address we got above.

Then press the “Update” button. Go back to the zabbix main dashboard and within a couple of minutes, the problem originally seen will disappear.

And if you go to Monitoring > Latest data, and select “Zabbix server” and apply it, you should see the latest values coming in as shown below.

Install Zabbix In Docker

Create a host definition

In order to validate that our definitions and data persist through the our planned upgrade from 4.0.1 -> 4.0-latest -> 4.2, we will now create a host definition with sample data.

This host will have a single trapper item named “mycount” that we will send manually using zabbix_sender (items of type “trapper” are sent by the agent, versus being queried for by the server).

First create a host definition by going to Configuration>Hosts and pressing the “Create Host” button. Then use “testhost1” as the hostname, “Linux servers” as the hostgroup, and press “Add”. This will create the host definition in the database.

This will get you back to the main hosts page, click on “items” on the “testhost1” row to add a field that will accept our data. Press the “Create item” button. Use “mycount” as both the name and key, and use the type of “Zabbix trapper”. Press the “Add” button.

Now that the host and field are created on the zabbix side, we need to send data.

The zabbix-agent container has a “zabbix_sender” binary available. We wil use it to send values to mycount.

If there is a failure, give the host and item a couple of minutes to sync and then retry. When successful, you will see a message like below that says “failed: 0”:

And if you go to Monitoring>Latest data and select the hostname of “testhost1” you should see the latest value sent. Pressing the “graph” link will show you a history of the values you have sent. Beware that you will not always see every value, because this in an aggregated metric fit into a time bucket.

Upgrading to Zabbix 4.0.13

The previous work with setting up hosts was to show that upgrades can be accomplished without losing data. The zabbix binaries are running in containers, but the ‘zbx_env’ directory is where the persistent volumes are kept for the MySql database, external scripts, etc. and will survive through upgrades.

There are several signficant changes between 4.0.1 and 4.0.13 including mysql changing to mysql:8.0 in 4.0.7, and starting in 4.0.10 Docker secrets were introduced, but all these details will be hidden from you during the image upgrade including the required database schema changes.

Checkout the latest 4.0.13 tag from source control. The yml file by default references “4.0-latest” so there is no need to modify it like we did for 4.0.1. Then have Docker Compose bring it back up.

Give the operation a few minutes, and the database time to be updated.

Because the containers were rebuilt, the nginx container fronting the web interface may have changed. Check the IP address again using the command below, then go to the Zabbix Admin web interface using this IP address.

If you scroll to the very bottom of the main Admin web page, you should see “Zabbix 4.0.13” reported. And looking at the latest data you should be able to see testhost1.mycount has the same historical values as before.

Let’s go ahead and send a value of “2” to the mycount item.

And now if we look at the latest data graph for testhost1.mycount, the min/max=1/2, and we can see the graph visualize this change.

Install Zabbix Proxy Docker

Upgrading to Zabbix 4.2-latest

The last step is to upgrade to the next major release, 4.2-latest. First stop the currently running 4.0-latest images, and verify they are gone.

Then checkout the 4.2 branch from source control . The yml file already references “4.2-latest” so there is no need to modify it. Then have Docker Compose bring it back up.

Give the operation a few minutes, and the database time to be updated.

Then find the IP address of the fronting nginx again:

And use this IP to open your browser to the Zabbix Admin web interface again. If you scroll to the very bottom of the main page, you should see “Zabbix 4.2.7” reported.

Now send a value of “3” to the mycount item.

Install Zabbix Docker Ubuntu

The latest data will reflect a min/max of 1/3 and visually you can see the growth from 1 (using zabbix 4.0.1) to 2 (using zabbix 4.1.13) to 3 (using the latest zabbix 4.2 branch).

REFERENCES

Install Zabbix Agent On Docker Container

NOTES

shell into container

view the differences between different git versions of file

Bring down just the mysql database, gracefully

copying external volumes so it could be restored if necessary

Checking mysql version

went from using values to secrets between 4.0.1 and 4.0.13

test bringing up only single component

If you do a “docker-compose kill” with default SIGKILL, the mysql database will register this as a crash next time you startup. Need to send SIGTERM instead (-s SIGTERM). This will recover for the same version, but for upgrades will fail and the image will have to be rolled back.

As a comparison, here are the logs when issuing a SIGTERM

docker-compose ‘kill’ can do graceful stop if you send custom signal

In addition to SIGTERM, you can also do a graceful shutdown with: