# Zabbix Enterprise Monitoring

> Complete Zabbix stack with server, web, agent, and PostgreSQL backend.

- Category: Monitoring & Observability
- Difficulty: intermediate
- Components: zabbix-server, zabbix-web, zabbix-agent, postgresql, nginx
- Tags: zabbix, monitoring, enterprise, alerting, snmp
- Source: https://docker.recipes/monitoring/zabbix-complete

## Overview

Zabbix Server is an open-source enterprise-class network monitoring solution that has been providing comprehensive infrastructure monitoring capabilities for over two decades. Originally developed by Alexei Vladishev in 2001, Zabbix excels at monitoring network services, servers, virtual machines, cloud resources, applications, and IoT devices through multiple collection methods including SNMP, IPMI, JMX, and custom agents. The platform stands out for its ability to handle millions of metrics while providing real-time visualization, flexible alerting, and automated discovery of network resources. This complete monitoring stack combines Zabbix Server with PostgreSQL as the backend database, delivering enterprise-grade performance and reliability. PostgreSQL's advanced indexing capabilities and ACID compliance make it ideal for storing the massive amounts of time-series data that Zabbix generates, while its JSON support enables flexible metadata storage for monitored items. The integrated NGINX web server provides high-performance delivery of the Zabbix web interface, handling concurrent user sessions efficiently while serving dashboards, graphs, and configuration screens. Organizations requiring comprehensive infrastructure visibility will find this stack particularly valuable for its scalability and depth of monitoring capabilities. Unlike simple uptime monitors or basic metrics collectors, this Zabbix deployment can handle complex monitoring scenarios including network topology mapping, predictive analytics through trend functions, and sophisticated alerting workflows with escalation chains and maintenance windows.

## Features

- Real-time monitoring with sub-second item collection intervals and immediate problem detection
- Advanced trigger expressions supporting statistical functions, trend analysis, and predictive forecasting
- Auto-discovery rules for automatic detection of network devices, file systems, and database instances
- Template-based monitoring with inheritance and macro support for scalable configuration management
- Native SNMP v1/v2c/v3 support for monitoring network equipment from all major vendors
- Low-level discovery (LLD) for automatic creation of items, triggers, and graphs for dynamic resources
- Distributed monitoring with proxy servers for remote location monitoring and reduced network overhead
- Flexible alerting with media types including email, SMS, webhooks, and custom script execution

## Use cases

- Enterprise data center monitoring with thousands of servers, network devices, and applications
- Multi-tenant service provider infrastructure monitoring with customer-specific dashboards and SLAs
- DevOps teams monitoring containerized applications and microservices architectures
- Network operations centers (NOCs) requiring 24/7 infrastructure visibility and incident response
- Compliance monitoring for industries requiring audit trails and availability reporting
- IoT device monitoring in manufacturing, smart city, or industrial automation environments
- Cloud hybrid monitoring combining on-premises infrastructure with AWS, Azure, or GCP resources

## Prerequisites

- Minimum 4GB RAM recommended for small environments (up to 1000 monitored items)
- Docker Engine 20.10+ and Docker Compose v2 for container orchestration support
- Available ports 8080, 8443, and 10051 for web interface and server communication
- Basic understanding of SNMP, network protocols, and monitoring concepts
- PostgreSQL administration knowledge for database maintenance and performance tuning
- Familiarity with Zabbix template system and trigger expression syntax

## docker-compose.yml

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

  zabbix-server:
    image: zabbix/zabbix-server-pgsql:latest
    environment:
      - DB_SERVER_HOST=postgres
      - POSTGRES_USER=zabbix
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=zabbix
    ports:
      - "10051:10051"
    volumes:
      - zabbix_data:/var/lib/zabbix
    depends_on:
      - postgres
    networks:
      - zabbix_net

  zabbix-web:
    image: zabbix/zabbix-web-nginx-pgsql:latest
    environment:
      - ZBX_SERVER_HOST=zabbix-server
      - DB_SERVER_HOST=postgres
      - POSTGRES_USER=zabbix
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=zabbix
      - PHP_TZ=UTC
    ports:
      - "8080:8080"
      - "8443:8443"
    depends_on:
      - zabbix-server
    networks:
      - zabbix_net

  zabbix-agent:
    image: zabbix/zabbix-agent:latest
    environment:
      - ZBX_SERVER_HOST=zabbix-server
      - ZBX_HOSTNAME=zabbix-agent
    privileged: true
    pid: host
    depends_on:
      - zabbix-server
    networks:
      - zabbix_net

  zabbix-agent2:
    image: zabbix/zabbix-agent2:latest
    environment:
      - ZBX_SERVER_HOST=zabbix-server
      - ZBX_HOSTNAME=zabbix-agent2
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    depends_on:
      - zabbix-server
    networks:
      - zabbix_net

volumes:
  postgres_data:
  zabbix_data:

networks:
  zabbix_net:
```

## .env

```bash
# Zabbix Monitoring
POSTGRES_PASSWORD=secure_postgres_password

# Zabbix Web at http://localhost:8080
# Default: Admin/zabbix
```

## Usage notes

- Web UI at http://localhost:8080
- Default credentials: Admin/zabbix
- Agent2 supports Docker monitoring
- SNMP and IPMI monitoring
- Template-based configuration

## Troubleshooting

- Zabbix server cannot connect to database: Verify POSTGRES_PASSWORD environment variable matches across all services and check postgres container logs for authentication errors
- Web interface shows 'Zabbix server is not running': Ensure zabbix-server container started successfully and check port 10051 connectivity between web and server containers
- Items showing 'Timeout while connecting to Zabbix Agent': Configure host firewall rules to allow connections from zabbix-server container IP range on port 10050
- High database CPU usage with slow queries: Implement PostgreSQL query optimization by creating indexes on history and trends tables, consider partitioning for large datasets
- Agent auto-registration failing: Verify ZBX_SERVER_HOST environment variable in agent containers points to correct zabbix-server service name and check network connectivity
- SNMP monitoring not working: Confirm SNMP community strings or v3 credentials are correct and target devices have SNMP enabled with proper access control lists

