# Step 1: Install Zabbix Agent on the PostgreSQL Server
# Install Zabbix repository (Ubuntu example)
sudo wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo apt update
# Install Zabbix Agent
sudo apt install zabbix-agent
# Step 2: Configure Zabbix Agent
# Edit Zabbix agent configuration
sudo nano /etc/zabbix/zabbix_agentd.conf
# Make changes to the file:
# Server=<Zabbix server IP>
# ServerActive=<Zabbix server IP>
# Hostname=<Name of the PostgreSQL server>
# Restart Zabbix Agent
sudo systemctl restart zabbix-agent
# Step 3: Configure PostgreSQL for Monitoring
# Edit PostgreSQL configuration file
sudo nano /etc/postgresql/12/main/postgresql.conf
# Add or uncomment the following lines:
# shared_preload_libraries = 'pg_stat_statements'
# pg_stat_statements.track = all
# Restart PostgreSQL to apply changes
sudo systemctl restart postgresql
# Create a monitoring role in PostgreSQL
sudo -u postgres psql -c "CREATE ROLE zabbix WITH LOGIN PASSWORD 'zabbix_password';"
sudo -u postgres psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO zabbix;"
# Step 4: Set up the Zabbix Template and Items
# Import PostgreSQL monitoring template in Zabbix server (manually via Zabbix UI)
# Path: Configuration > Templates > Import
# Link the template to your host in Zabbix server
# Path: Configuration > Hosts > select your host > Templates tab > Add the PostgreSQL template > Update
# Step 5: Test and Validate
# Check if data is being collected in Zabbix server
# Path: Monitoring > Latest Data > Filter by your PostgreSQL server's name
# Troubleshoot any issues by checking logs
# Check Zabbix Agent logs
cat /var/log/zabbix/zabbix_agentd.log
# Check PostgreSQL logs
cat /var/log/postgresql/postgresql-12-main.log
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND