# Zabbix Monitoring

> Enterprise-class monitoring solution for networks and applications.

- Category: Monitoring & Observability
- Difficulty: advanced
- Components: zabbix-server, zabbix-web, postgres
- Tags: zabbix, enterprise, network, monitoring
- Source: https://docker.recipes/monitoring/zabbix

## Overview

Zabbix is an enterprise-grade monitoring platform developed since 2001 that provides comprehensive network, server, and application monitoring capabilities. The Zabbix server acts as the central processing engine, collecting and analyzing metrics from monitored hosts through multiple protocols including SNMP, IPMI, JMX, and custom agent communications. It processes trigger conditions, generates alerts, and maintains historical data for trend analysis and capacity planning. This stack combines the Zabbix server with PostgreSQL as the backend database and the Nginx-based web frontend, creating a complete monitoring infrastructure. PostgreSQL serves as the robust data repository for storing configuration data, historical metrics, events, and user settings, while the web interface provides visualization through dashboards, graphs, and administrative controls. The architecture supports distributed monitoring with proxy servers and can scale to monitor thousands of devices across multiple network segments. Organizations deploy this combination when they need enterprise-level monitoring with advanced features like predictive triggering, complex event correlation, and detailed performance analytics. The PostgreSQL backend ensures ACID compliance for critical monitoring data, while the Zabbix server's flexible template system and auto-discovery capabilities make it suitable for dynamic environments where infrastructure changes frequently.

## Features

- Multi-protocol data collection supporting Zabbix agents, SNMP v1/v2c/v3, IPMI, JMX, and SSH checks
- Advanced trigger expressions with predictive functions and complex mathematical calculations
- Auto-discovery of network devices, services, and file systems with automated host provisioning
- Template inheritance system allowing hierarchical monitoring configuration management
- PostgreSQL backend with partitioned tables for efficient storage of time-series monitoring data
- Real-time and historical data visualization with customizable dashboards and graph widgets
- Flexible notification system supporting email, SMS, Slack, and custom webhook integrations
- Distributed monitoring architecture with proxy support for monitoring remote networks

## Use cases

- Enterprise network operations centers monitoring thousands of network devices and servers
- Cloud infrastructure monitoring with auto-discovery of dynamic AWS, Azure, or GCP resources
- Application performance monitoring for web services with custom JMX and database metrics
- IoT device monitoring using SNMP and custom protocols for industrial equipment
- Compliance monitoring for SOX, HIPAA, or PCI-DSS requiring detailed audit trails
- Hybrid cloud monitoring spanning on-premises data centers and public cloud instances
- MSP (Managed Service Provider) multi-tenant monitoring with separate client dashboards

## Prerequisites

- Minimum 2GB RAM recommended (Zabbix server requires 1GB+ for moderate loads)
- Available ports 8080 (web interface), 10051 (Zabbix server), and 10050 (agent communications)
- Understanding of SNMP, network protocols, and basic database administration concepts
- PostgreSQL password configured in environment variables or .env file
- Network access to devices you plan to monitor via SNMP, SSH, or Zabbix agent protocols
- Time synchronization across monitored infrastructure for accurate event correlation

## docker-compose.yml

```yaml
services:
  postgres:
    image: postgres:16-alpine
    container_name: zabbix-postgres
    environment:
      POSTGRES_USER: zabbix
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: zabbix
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - zabbix

  zabbix-server:
    image: zabbix/zabbix-server-pgsql:alpine-6.4-latest
    container_name: zabbix-server
    environment:
      DB_SERVER_HOST: postgres
      POSTGRES_USER: zabbix
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "10051:10051"
    depends_on:
      - postgres
    networks:
      - zabbix

  zabbix-web:
    image: zabbix/zabbix-web-nginx-pgsql:alpine-6.4-latest
    container_name: zabbix-web
    environment:
      DB_SERVER_HOST: postgres
      POSTGRES_USER: zabbix
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      ZBX_SERVER_HOST: zabbix-server
    ports:
      - "8080:8080"
    depends_on:
      - zabbix-server
    networks:
      - zabbix

volumes:
  postgres_data:

networks:
  zabbix:
    driver: bridge
```

## .env

```bash
POSTGRES_PASSWORD=changeme
```

## Usage notes

- Docs: https://www.zabbix.com/documentation/current/
- Web UI at http://localhost:8080 - default Admin/zabbix
- Install Zabbix agents on hosts to monitor them
- Import templates from Configuration > Templates for common services
- Agent port 10050, server port 10051 for active checks
- Supports SNMP, IPMI, JMX, and custom scripts for data collection

## Troubleshooting

- Zabbix server cannot connect to PostgreSQL: Verify POSTGRES_PASSWORD environment variable matches across all services and PostgreSQL container is fully initialized
- Web interface shows database connection error: Check that zabbix-server container has completed database schema creation before zabbix-web starts, add restart: unless-stopped to handle race conditions
- Hosts show as unreachable in monitoring: Ensure Zabbix agent port 10050 is open on target hosts and zabbix-server container can access your network segment
- Performance issues with large datasets: Tune PostgreSQL shared_buffers and work_mem settings, consider implementing table partitioning for history and trends tables
- Memory usage growing continuously: Configure housekeeping settings in Administration > General > Housekeeping to automatically remove old historical data
- Alert notifications not working: Verify media types configuration and test SMTP/webhook connectivity from within the zabbix-server container network context

