- CSS 78.5%
- Python 12.7%
- Shell 7.3%
- Dockerfile 1.2%
- PHP 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| env | ||
| src | ||
| docker-compose.yml | ||
| README.md | ||
| zabbix.service | ||
| zabbix_sudoers | ||
Install Zabbix 7 + TimescaleDB monitoring server in docker
Greetings!
In this tutorial, we will deploy the popular Zabbix monitoring system using TimescaleDB , a PostgreSQL database plugin that allows you to effectively work with “time series”. We will wrap all this goodness inside docker containers 🐳. It will be interesting 😉.
Please note that all actions described in this guide are done at your own risk and responsibility. My blog is just a platform where I talk about my experience and share my opinion on some things and phenomena. Thank you for understanding.
Ivan Cherniy
- Install Zabbix 7 + TimescaleDB monitoring server in docker
Introduction
Zabbix is an open platform for monitoring networks and servers. It uses relational DBMS for data storage, such as PostgreSQL, MySQL, MariaDB, Oracle, SQLite, etc.
A time series in databases is a set of data ordered by time, where values are recorded at equal or unequal time intervals.
Time series databases are specialized databases designed for efficient storage, management, and analysis of time series. These are often no sql databases.
TimescaleDB (TSDB) is an extension for PostgreSQL that optimizes work with time series in this DBMS, while maintaining all the power and flexibility of classic SQL-like databases. Since a certain time, Zabbix has learned to work with this DBMS.
Quote from the official Zabbix documentation:
Zabbix supports TimescaleDB, a PostgreSQL-based database solution of automatically partitioning data into time-based chunks to support faster performance at scale.
Zabbix.com
Please also pay attention to the warning from the official Zabbix documentation:
Warning: Currently, TimescaleDB is not supported by Zabbix proxy.
Zabbix.com 09.2024
I'm sure this will be fixed in the future. But for now, enough chatter, let's get down to business🤵♂️.
Preparation
We will deploy Zabbix in the Debian 12 💿 distribution environment with the Docker engine 🐳 installed. If you don’t have a ready-made Linux server yet, I recommend my previous articles:
- Installing Debian 12 Server in VirtualBox
- Initial setup of Linux server using Debian as an example
- Installing Docker engine on a Linux server running Debian
Also, for further work we will need a user with root rights .
Hey, this article is part of a series about building your own infrastructure. Previous articles:
- Install OpenConnect SSL VPN server (ocserv) in docker for internal projects
- Install your own DNS server Unbound and ad blocker Pihole in docker
And here is the diagram, taking into account the addition of a monitoring server:
Installing the necessary utilities
Today we will need utilities for interaction with the web. Open the terminal and install the version control system gitand the utility curl:
sudo apt update && sudo apt install -y git curl
Downloading project files
All project files are in my repository on git.r4ven.me . Clone it using the previously installed utility gitalong the path /opt/zabbix:
sudo git clone https://git.r4ven.me/compose/zabbix /opt/zabbix
Click here to view the description of the project files
docker-compose.yml– file describing services launched in docker containers:- The NETWORK section defines two docker virtual networks:
zbx_net_backend– an isolated network for interaction between containerspostgres-server,zabbix-server,zabbix-webandzabbix-agent;zbx_net_frontend– network with access to containers from the host OS: for containerszabbix-serverandzabbix-web.
- The SERVICES section defines the parameters of the services/containers being launched:
postgres-server– TimescaleDB DBMS service;zabbix-server– Zabbix server service;zabbix-web– web interface service for Zabbix server (under the hood nginx + php-fpm );zabbix-agent– Zabbix agent service for collecting metrics from the Zabbix server itself.
- The SECRETS section defines files containing sensitive information that are dropped into containers
postgres-server,zabbix-serverandzabbix-web:POSTGRES_USER(file./env/.POSTGRES_USER) – user name for the Zabbix database in the TimescaleDB DBMS;POSTGRES_PASSWORD(file./env/.POSTGRES_PASSWORD) – respectively, the user password.
- The NETWORK section defines two docker virtual networks:
- env – a directory with files containing environment variables, the values of which are passed inside the container when it is launched:
.env_db– parameters forpostgres-server;.env_srv– parameters forzabbix-server;.env_web– parameters forzabbix-web;.env_agent– parameters for localzabbix-agent;.POSTGRES_PASSWORD– user password in the zabbix database;.POSTGRES_USER– user name in the zabbix database.
src– directory with source files for building a custom containerzabbix-serverwith extended functionality:alertscripts– directory with files for sending notifications to Telegram:docker-entrypoint.sh– script for preparing the environment inside the container (not changed);Dockerfile– customized image build description file;externalscripts– a directory with a script for monitoring the delegated domain.
If necessary, edit the block deployfor the required services in the file docker-compose.yml, depending on the server resources you have. By default, the minimum values are used.
Creating a zabbix service user
For security purposes, we create a group with limited rights and a service user to run zabbix containers:
sudo addgroup --system --gid 1995 zabbix
sudo adduser --system --gecos "Zabbix monitoring system" \
--disabled-password --uid 1997 --ingroup zabbix \
--shell /sbin/nologin --home /opt/zabbix/zabbix_data zabbix
Create a postgres service user
Now, in a similar way, we create a group and user to run the TimescaleDB container:
sudo addgroup --system --gid 70 postgres
sudo adduser --system --gecos "PostgreSQL database" \
--disabled-password --uid 70 --ingroup postgres \
--shell /sbin/nologin --home /opt/zabbix/postgres_data postgres
We check the presence of all necessary files and folders:
ls -l /opt/zabbix
Great, let's move on 🚶.
Creating a Password for a Postgres Database
By default, /opt/zabbix/env/.POSTGRES_PASSWORDI set the same password for the zabbix database in the file. But I highly recommend generating a new one, for example with this command:
tr -cd "[:alnum:]" < /dev/urandom | head -c 30 \
| sudo tee /opt/zabbix/env/.POSTGRES_PASSWORD
Ignore the character
%at the end of my example line. This is a quirk of the ZSH shell , which prints it (or#for root) when there is no newline character.
Running Zabbix stack with docker compose
Start the Postgres server
First, we launch the DBMS server with the following command:
sudo docker compose -f /opt/zabbix/docker-compose.yml up -d postgres-server
After loading the image and running the container, we look at its output:
sudo docker logs -f postgres-server
If launched successfully, you will see something like this:
At the first start, scripts for preparing the environment and basic DBMS configuration are executed inside the container depending on the server parameters. In one of my tests, such a script set the parameter max_connectionsequal 25- which is not enough even to import the zabbix DB schema and the process will fail with an error:
FATAL: sorry, too many clients already
You can check the value max_connectionswith this command:
sudo grep 'max_connections' /opt/zabbix/postgres_data/postgresql.conf
If you have <=25, then this parameter needs to be increased. Open the file for editing with any console editor, for example, Vim/Neovim 😎:
sudo vim /opt/zabbix/postgres_data/postgresql.conf
We find the line there:
max_connections = 25
And we change it, for example, to:
max_connections = 200
Save the file and exit the editor.
To apply the changes, restart the container postgres-serverand check the current value max_connections:
sudo docker compose -f /opt/zabbix/docker-compose.yml restart postgres-server
sudo docker exec -it postgres-server psql -U zabbix -c "SHOW max_connections;"
Everything has been applied, let's move on to launching the container zabbix-server.
Starting Zabbix Server
We launch it with the following command:
sudo docker compose -f /opt/zabbix/docker-compose.yml up -d zabbix-server
Let's look at the container output:
sudo docker logs -f zabbix-server
When you first run the container, it will start creating the database. This will take some time. The output will stop at this line:
Creating 'zabbix' schema in PostgreSQL
Be sure to wait until the database creation procedure is completed!
If it runs successfully, you should see something like this:
Perhaps at the very end there will be a conclusion similar to this:
256:20240922:121849.602 Zabbix agent item "system.cpu.util[,system]" on host "Zabbix server" failed: first network error, wait for 15 seconds
225:20240922:121855.944 item "Zabbix server:zabbix[vmware,buffer,pused]" became not supported: No "vmware collector" processes started.
225:20240922:121858.958 item "Zabbix server:zabbix[process,report writer,avg,busy]" became not supported: No "report writer" processes started.
225:20240922:121859.962 item "Zabbix server:zabbix[process,report manager,avg,busy]" became not supported: No "report manager" processes started.
256:20240922:121904.599 Zabbix agent item "system.users.num" on host "Zabbix server" failed: another network error, wait for 15 seconds
256:20240922:121919.602 Zabbix agent item "system.cpu.load[all,avg5]" on host "Zabbix server" failed: another network error, wait for 15 seconds
225:20240922:121928.010 item "Zabbix server:zabbix[connector_queue]" became not supported: connector is not initialized: please check "StartConnectors" configuration parameter
225:20240922:121929.016 item "Zabbix server:zabbix[process,connector manager,avg,busy]" became not supported: No "connector manager" processes started.
225:20240922:121930.021 item "Zabbix server:zabbix[process,connector worker,avg,busy]" became not supported: No "connector worker" processes started.
256:20240922:121934.600 temporarily disabling Zabbix agent checks on host "Zabbix server": interface unavailable
We don't pay attention to him.
Check the status of running containers:
sudo docker ps
Everything is ok – let's move on.
Creating a Schema for TimescaleDB
We output the password created earlier to the terminal, we will need it soon. Then we connect to the container shell zabbix-server:
sudo cat /opt/zabbix/env/.POSTGRES_PASSWORD
sudo docker exec -it zabbix-server bash
Now we import the TimescaleDB schema using the SQL script that the Zabbix developers kindly put in the system files. When entering the import command, we will be asked for the DB password that we got in the previous step:
psql -h postgres-server -U zabbix zabbix < /usr/share/doc/zabbix-server-postgresql/timescaledb.sql
The import process is a simple redirection of the contents of the SQL script to the input of the database connection command using psql.
The output should be:
We exit the container zabbix-serverand check for information about chunks in Postgres:
exit
sudo docker exec -it postgres-server \
psql -U zabbix -c "SELECT * FROM chunks_detailed_size('history')"
If your output is the same as in the screenshot above, then everything was imported successfully 🥳.
At this stage, the Postgres/TimesacleDB database and Zabbix server are ready 😉.
Starting the whole stack TimesacleDB + Zabbix server + Zabbix web + Zabbix agent
We stop running containers and start the entire installation, including Zabbix web and Zabbix agent:
sudo docker compose -f /opt/zabbix/docker-compose.yml down
sudo docker compose -f /opt/zabbix/docker-compose.yml up -d
Let's check if all containers started correctly:
sudo docker ps
sudo docker compose -f /opt/zabbix/docker-compose.yml logs -f
Great. Now let's check the operation of Zabbix itself:
curl -I http://localhost:8080
nc -zv localhost 10051
ss -tulnap | grep -E '8080|10051'
With the first command we checked the availability of the web interface from the console, with the second – the availability of the port
zabbix-server, and with the third we displayed the ports listened to by the host OS.
Great, everything works 🎉🎉🎉.
Access to Zabbix web interface
The way to access the Zabbix web interface depends on the conditions in which you deployed the stack. I will describe several obvious options.
Click on the spoiler to view the instructions.
1) If Zabbix server is deployed on a local machine
Just type the URL into your browser 😁😁😁:
http://127.0.0.1:8080/
2) If Zabbix server is deployed on a remote server that is located in a local or VPN network
In this case, edit the network settings for services zabbix-serverand zabbix-webin docker-compose.ymlthe file.
For example, the internal address of my server in the VPN network is: 192.168.122.24. I edit docker-compose.yml:
sudo vim /opt/zabbix/docker-compose.yml
zabbix-server:
zabbix-web:
I restart all containers:
sudo docker compose -f /opt/zabbix/docker-compose.yml down
sudo docker compose -f /opt/zabbix/docker-compose.yml up -d
sudo docker ps
On the client connected to the VPN network, I open the following URL in the browser:
http://192.168.122.24:8080/
3) If Zabbix server is deployed on a remote server and is not connected to a local or VPN network
In this case, you can forward an SSH port or open access directly or through a reverse proxy, like nginx . I will consider only the first case, as the simplest. And also because the other two are beyond the scope of this article 😜.
On the client, open the terminal and execute:
ssh -L 8080:127.0.0.1:8080 user@example.com
Where (in order):
-L– local port forwarding key;8080– the port that the client machine will listen to and redirect it to8080the server port;127.0.0.1– the address of the server on which it listens to the port;8080– accordingly the port to which we are redirecting;user@example.com– user and SSH server address.
In my example the command is:
Now open the browser and go to the address: http://127.0.0.1:8080/
Access to the web interface will be available as long as the SSH session is open.
To log in to the web interface, use the standard login: Adminand password:zabbix
If you saw this:
Congratulations 😎! Zabbix server with TimescaleDB is up and running 👷♂️.
Optional
Below are some optional but recommended steps of the instructions 😉.
Minimal initial setup of Zabbix server
Click on the spoiler
I won't go into too much detail about Zabbix settings, as this is a topic for more than one article 🤯. I'll just show you how to change the interface language, create a new user with admin rights, disable the standard Admin and configure a local Zabbix agent to monitor the Zabbix server itself.
All actions are shown in pictures and do not really need any comments 😏.
Change language
Create a new user
And we re-enter the interface under the new user:
Disabling the standard Admin user
Connecting a local Zabbix agent
This agent was raised by us at the moment of launching the entire installation and is accessible by domain name zabbix-agentwithin the container network.
Here we must select “Connect via” – DNS :
Now we go to the page “Monitoring” – “Problems”. In a few minutes the problem with local availability zabbix-agentshould be solved:
Setting up Zabbix stack autostart with systemd
Click on the spoiler
At the beginning of the article, we created a service user zabbix. We use it to securely run Zabbix stack services.
Setting up sudoers to run Zabbix as a service user
Recently I have been examining the intricacies of the privilege escalation mechanism in Linux. For a better understanding of further actions I recommend reading: Linux command line, privilege escalation: su, sudo commands 😌.
Create a new file with a description of limited permissions for the zabbix user:
sudo visudo -f /etc/sudoers.d/zabbix
And fill it with the following:
Cmnd_Alias ZBX = \
/usr/bin/docker compose -f /opt/zabbix/docker-compose.yml up, \
/usr/bin/docker compose -f /opt/zabbix/docker-compose.yml down
zabbix ALL = (:docker) NOPASSWD: ZBX
We allow the zabbix user to start and stop the services described in our , on behalf of the privileged docker
docker-compose.ymlgroup using .sudo
Save the file and close the editor.
Creating a systemd service file
Open for editing:
sudo vim /etc/systemd/system/zabbix.service
And we fill it:
[Unit]
Description=Zabbix service
Requires=docker.service
After=docker.service
[Service]
Restart=always
RestartSec=5
User=zabbix
ExecStart=/usr/bin/sudo --group=docker /usr/bin/docker compose -f /opt/zabbix/docker-compose.yml up
ExecStop=/usr/bin/sudo --group=docker /usr/bin/docker compose -f /opt/zabbix/docker-compose.yml down
[Install]
WantedBy=multi-user.target
Save, close. After that, stop the running containers, reread the systemd configuration, activate the autostart of the zabbix service and start it:
sudo docker compose -f /opt/zabbix/docker-compose.yml down
sudo systemctl enable --now zabbix
sudo systemctl status zabbix
Checking the status of containers:
sudo docker ps
Everything is running. That's great 🙂.
Installing and running Zabbix agent in docker on a remote host
Click on the spoiler
Since we deployed Zabbix in Docker, the logical step would be to launch Zabbix agents in a similar way.
Obviously, this requires the Docker engine to be installed and running .
Downloading project files and creating a service user
Clone the repository with files:
sudo git clone https://git.r4ven.me/compose/zabbix-agent /opt/zabbix-agent
As in the case of the server, we create a service user to run the Zabbix agent:
sudo addgroup --system --gid 1995 zabbix
sudo adduser --system --gecos "Zabbix agent" \
--disabled-password --uid 1997 --ingroup zabbix \
--shell /sbin/nologin --home /opt/zabbix-agent/data zabbix
We correct .envthe file – the file with Zabbix agent parameters.
sudo vim /opt/zabbix-agent/.env
Here we must specify the existing IP address of the host on which the Zabbix agent service will wait for connections. We also specify the agent hostname and the Zabbix server address.
In my example the data is:
- Zabbix server address:
192.168.122.24 - Zabbix agent address:
192.168.122.105 - Zabbix agent hostname:
zabbix-agent.example.com
Description of all parameters can be found here .
Now, just in case, we check the finished sudoers file and if everything is ok, we copy it to /etc/sudoers.d/:
sudo visudo -c -f /opt/zabbix-agent/zabbix_agent
sudo cp /opt/zabbix-agent/zabbix_agent /etc/sudoers.d/
Next, we copy the systemd service file, reread the configuration and run it zabbix-agent:
sudo cp /opt/zabbix-agent/zabbix-agent.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now zabbix-agent
Please note that when you first run docker, it will download the image from the registry.
You can check the agent status with the following commands:
sudo systemctl status zabbix-agent
sudo journalctl -fu zabbix-agent
sudo docker ps
Zabbix agent is running.
Nuance. If you have many external partitions mounted on your server, you need to add them to the block volumein docker-compose.ymlorder for the Zabbix agent to detect them.
Adding Zabbix Agent to Zabbix Server
Almost everything is in pictures here 😇.
Go to “Monitoring” – “Network nodes” and after a while:
Hooray!🥳🥳🥳
Setting up Zabbix notifications in Telegram with a schedule
Click on the spoiler
And now the interesting part 🧐. To implement the ability to send emergency notifications to Telegram with graphs, I rebuilt the container zabbix-server, adding a Python interpreter , a special venv and files from the GitHub repository of the developer xxsokolov - this method is marked on the official Zabbix website as valid 👌.
In the instructions below, the option of using my image is considered: r4venme/zabbix-server-pgsql:alpine-7.0.3 , but you can also build your own. You will find all the files for the build in the downloaded repository from the beginning of the article, in the folder src.
Let's start setting up.
Creating an Alert Type (Web Interface)
- Name (optional):
Alerter - Type:
Скрипт - Script name:
zbxTelegram.py - Script parameters:
{ALERT.SENDTO}{ALERT.SUBJECT}{ALERT.MESSAGE}
Next, go to the templates tab and add 2 pieces: for problems and for recovery:
Template for problems:
- Message Type: Problem
- Subject:
{Problem} Problem ({TRIGGER.SEVERITY}) - Message:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<body>
<messages>
<![CDATA[
Problem: {EVENT.NAME}
Host: {HOST.NAME} ({HOST.IP})
Start at: {EVENT.TIME} {EVENT.DATE}
Last value: {ITEM.LASTVALUE1}
###########################
]]>
</messages>
</body>
<settings>
<graphs>True</graphs>
<hostlinks>True</hostlinks>
<graphlinks>False</graphlinks>
<acklinks>True</acklinks>
<eventlinks>True</eventlinks>
<triggerlinks>True</triggerlinks>
<eventtag>False</eventtag>
<eventidtag>False</eventidtag>
<itemidtag>False</itemidtag>
<triggeridtag>False</triggeridtag>
<actionidtag>False</actionidtag>
<hostidtag>False</hostidtag>
<zntsettingstag>True</zntsettingstag>
<zntmentions>True</zntmentions>
<keyboard>True</keyboard>
<graphs_period>default</graphs_period>
<host>{HOST.HOST}</host>
<itemid>{ITEM.ID1} {ITEM.ID2} {ITEM.ID3} {ITEM.ID4}</itemid>
<triggerid>{TRIGGER.ID}</triggerid>
<eventid>{EVENT.ID}</eventid>
<actionid>{ACTION.ID}</actionid>
<hostid>{HOST.ID}</hostid>
<title><![CDATA[{HOST.NAME} - {EVENT.NAME}]]></title>
<triggerurl><![CDATA[{TRIGGER.URL}]]></triggerurl>
<eventtags><![CDATA[{EVENT.TAGS}]]></eventtags>
</settings>
</root>
After filling in, click “Add”:
Then again “Add” the following:
Recovery template:
- Message Type: Problem Recovery
- Subject:
{Resolved} Recovery - Message:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<body>
<messages>
<![CDATA[
Problem: {EVENT.RECOVERY.NAME}
Host: {HOST.NAME} ({HOST.IP})
Duration: {EVENT.DURATION}
Recovery time: {EVENT.RECOVERY.TIME} {EVENT.RECOVERY.DATE}
Last value: {ITEM.LASTVALUE1}
###########################
]]>
</messages>
</body>
<settings>
<graphs>True</graphs>
<hostlinks>True</hostlinks>
<graphlinks>False</graphlinks>
<acklinks>True</acklinks>
<eventlinks>True</eventlinks>
<triggerlinks>True</triggerlinks>
<eventtag>False</eventtag>
<eventidtag>False</eventidtag>
<itemidtag>False</itemidtag>
<triggeridtag>False</triggeridtag>
<actionidtag>False</actionidtag>
<hostidtag>False</hostidtag>
<zntsettingstag>True</zntsettingstag>
<zntmentions>True</zntmentions>
<keyboard>True</keyboard>
<graphs_period>default</graphs_period>
<host>{HOST.HOST}</host>
<itemid>{ITEM.ID1} {ITEM.ID2} {ITEM.ID3} {ITEM.ID4}</itemid>
<triggerid>{TRIGGER.ID}</triggerid>
<eventid>{EVENT.ID}</eventid>
<actionid>{ACTION.ID}</actionid>
<hostid>{HOST.ID}</hostid>
<title><![CDATA[{HOST.NAME} - {EVENT.NAME}]]></title>
<triggerurl><![CDATA[{TRIGGER.URL}]]></triggerurl>
<eventtags><![CDATA[{EVENT.TAGS}]]></eventtags>
</settings>
</root>
Next “Add”:
And finally, here again:
It should look like this:
Creating a service user (web interface)
Now let's create a service user for sending notifications:
Fill in all the required fields:
The background of the graphs in notifications depends on the theme you choose.
After that, go to the “Notifications” tab and in the “Send to” field, specify the Telegram ID of the chat or group ( instructions from the official Zabbix website on how to get the ID ):
Next, go to “Access Rights”. Here, in a good way, you first need to set up limited groups and user roles. But this is a delicate process, and it is also beyond the scope of the article. For a quick solution, I give the service user “superadmin” rights, since the script requires read rights for network nodes and templates to work. This is up to you.
And at the end, click on the main “Add”:
Setting up notification conditions (web interface)
Go to “Trigger Actions” and create a new one:
We set the name and add the condition. In the condition we specify 2 templates, as in the screenshot:
Next, go to the “Operations” tab and add 2 actions there: for “Operations” and “Recovery operations”:
We specify the recipient - our service user, who registered the group/chat ID in the telegram. Here we also specify the sending method: the one we created earlier:
Something like this:
Editing docker-compose.yml (server console)
We return to the server and open it for editing:
sudo vim /opt/zabbix/docker-compose.yml
We edit the service zabbix-server, block image. We comment the current line, and uncomment the line with the address of the image I have assembled:
# image: zabbix/zabbix-server-pgsql:alpine-7.0.3
image: r4venme/zabbix-server-pgsql:alpine-7.0.3
Save and restart zabbix-server:
sudo systemctl restart zabbix
sudo journalctl -fu zabbix
sudo docker ps
zabbix-serverAfter launching, we create a folder of alarm scripts, copy the config file of the script for sending notifications to the telegram from the docker container and change its owner:
sudo mkdir -p /opt/zabbix/zabbix_data/server/alertscripts/
sudo docker cp zabbix-server:/usr/lib/zabbix/alertscripts/zbxTelegram_config.py \
/opt/zabbix/zabbix_data/server/alertscripts/
sudo chown -R zabbix:zabbix /opt/zabbix/zabbix_data/server/alertscripts/
Reopening docker-compose.yml:
sudo vim /opt/zabbix/docker-compose.yml
For the service zabbix-serverand in the block, volumeuncomment the following line:
- ./zabbix_data/server/alertscripts/zbxTelegram_config.py:/usr/lib/zabbix/alertscripts/zbxTelegram_config.py
Don't forget to save.
Sending settings (server console)
There's just a little bit left 🥺.
Open the copied config file for editing:
sudo vim /opt/zabbix/zabbix_data/server/alertscripts/zbxTelegram_config.py
And we specify the token of our bot ( how to get it ) in the line tg_tokeninside single quotes:
Scroll down the file and also specify the service user and password that we created earlier:
zabbix_api_url– this is the internal network address of the container. Do not touch it if you have not changed it.
Recreate the container zabbix-server:
sudo docker compose -f /opt/zabbix/docker-compose.yml down zabbix-server
sudo docker compose -f /opt/zabbix/docker-compose.yml up -d zabbix-server
Check (server console)
We check sending messages in the command line:
sudo docker exec -it zabbix-server \
/usr/lib/zabbix/alertscripts/zbxTelegram.py 1234567890 test test
Where
1234567890is the ID of the chat or group in Telegram.
It works 👍.
Testing in practice
If you connected the local one zabbix-agentduring the initial setup step, then to check it, simply stop it with the command:
sudo docker compose -f /opt/zabbix/docker-compose.yml stop zabbix-agent
Go to the web interface along the path: “Monitoring” – “Problems”. In a few minutes, the agent will receive the “Unavailable” status, the problem will appear on the corresponding web panel and you should receive a notification in Telegram.
The message arrived, great. Now let's launch the agent:
sudo docker compose -f /opt/zabbix/docker-compose.yml start zabbix-agent
In a few minutes it will be restored in the web panel and a corresponding notification will be sent to Telegram:
Lovely 🤤.
Conclusion
Phew..🤯 this wasn't the easiest article. Especially in terms of the amount of information we had to sift through. But I think it was worth it. As a result, we got a flexible and easily portable monitoring system project that works inside docker containers. We also set up concise but informative notifications with graphs in Telegram to always be aware of the state of our infrastructure.
I would also like to note the excellent work of Zabbix developers. In particular, the relevance and diversity of docker images and the availability of their build files. After writing this article, I respected them even more 👍.
Thank you for reading 😊. If you have any questions, I invite you to the Raven Chat , as you guessed, in Telegram 😅. We have a friendly community there 🚶♀️🐧🚶🐧🚶♂️🐧. And be sure to subscribe to the main Telegram channel: @r4ven_me , so as not to miss the publication of new materials on the site.
I wish you success and a successful salesman! 😌
Materials used
- My zabbix server repository | git.r4ven.me
- My zabbix agent repository | git.r4ven.me
- Using TimescaleDB with Zabbix | Zabbix.com (EN)
- The original docker files I adapted | GitHub
- TimescaleDB docker image registry | Dockerhub
- Description of the PostgresSQL docker image | Dockerhub
- TimescaleDB docker image sources | GitHub
- Description of Zabbix server docker image | Dockerhub
- Description of the Zabbix web docker image | Dockerhub
- Description of Zabbix agent docker image | Dockerhub
- Source Dockerfile for Zabbix server | GitHub
- Zabbix Notification Telegram Source Files | GitHub
- Description of Zabbix Notification Telegram script | GitHub
- Zabbix Notification Telegram Installation Guide | GitHub





























































































