News
Faster Speeds: Bandwidth for vStack Servers in Kazakhstan Increased to 200 Mbps
BS
June 28 2025
Updated June 24 2025

Zabbix for Virtual Database Monitoring Performance Tracking Made Easy

Zabbix

Virtual databases (in the cloud, on VMs, or in containers) are the backbone of modern applications. However, their dynamic nature creates challenges: from resource contention to hidden failures invisible at the OS level. Without robust monitoring, these issues lead to downtime and losses. Zabbix is an open-source tool that enables comprehensive monitoring of database health across all layers, from infrastructure to business metrics. This guide will help you set up monitoring for virtual databases using Zabbix, ensuring transparency and control.

Deploying Zabbix

Architecture:

[Пользователь] → [Ingress] → [PrestaShop Pods] → [Redis] → [MariaDB] - visual selection (4)
Picture 1 - Zabbix

Installation Steps:

1. Install Server: Sets up the server and web interface with PostgreSQL support.

# Install Zabbix on Ubuntu

wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb

dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb

apt update

apt install zabbix-server-pgsql zabbix-frontend-php php-pgsql zabbix-apache-conf

2. Configure Database: Creates a database for Zabbix data storage.

CREATE DATABASE zabbix_db;

CREATE USER zabbix_user WITH PASSWORD 'StrongPassword';

GRANT ALL PRIVILEGES ON DATABASE zabbix_db TO zabbix_user;

3. Import Schema: Populates the database with initial data.

zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix_db

4. Configure Server: Connects the server to the database.

# /etc/zabbix/zabbix_server.conf

DBHost=localhost

DBName=zabbix_db

DBUser=zabbix_user

DBPassword=StrongPassword

5. Start Services: Launches Zabbix and the web server.

systemctl restart zabbix-server apache2

systemctl enable zabbix-server

Configuring PostgreSQL Monitoring

1. Install Agent: The agent collects metrics from the database server.

apt install zabbix-agent

2. Configure Access: Create a user for PostgreSQL monitoring.

CREATE USER zabbix_mon WITH PASSWORD 'MonitorPass';

GRANT pg_monitor TO zabbix_mon;

3. Configure Agent: Defines custom parameters for metric collection.

# /etc/zabbix/zabbix_agentd.conf

UserParameter=pg.connections[*], psql -U zabbix_mon -c "SELECT COUNT(*) FROM pg_stat_activity WHERE state = 'active'" -t

UserParameter=pg.locks[*], psql -U zabbix_mon -c "SELECT COUNT(*) FROM pg_locks" -t

4. Configure Template in Zabbix:

  • Import "PostgreSQL by Zabbix agent".
  • Assign to the host.
  • Set macros: `{$PG.USER}=zabbix_mon`, `{$PG.PASSWORD}=MonitorPass`.

Configuring MySQL Monitoring

1. Create User: Create a user for MySQL monitoring.

CREATE USER 'zabbix_mon'@'localhost' IDENTIFIED BY 'MonitorPass';

GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'zabbix_mon'@'localhost';

GRANT SELECT ON performance_schema.* TO 'zabbix_mon'@'localhost';

2. Configure Access: Simplifies agent connection.

# ~/.my.cnf

[client]

user=zabbix_mon

password=MonitorPass

3. Configure Agent: Collects basic MySQL metrics.

# /etc/zabbix/zabbix_agentd.conf

UserParameter=mysql.connections,mysqladmin status | awk '{print $$4}'

UserParameter=mysql.queries_per_sec,mysqladmin status | awk '{print $$6}'

4. Use Template: Apply "MySQL by Zabbix agent" with macros:

`{$MYSQL.USER}=zabbix_mon`, `{$MYSQL.PASSWORD}=MonitorPass`.

Key Metrics for SRE

Example Trigger:

Fires if the number of connections exceeds 90% of the maximum.

{Template DB PostgreSQL:pg.connections.last()} /

{Template DB PostgreSQL:pg.max_connections.last()} * 100 > 90

Zabbix provides deep monitoring of virtual databases, enabling SREs to predict and prevent issues. This guide offers a basic setup for PostgreSQL and MySQL, which can be extended to meet your needs.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.