Skip to content

About

zabbix nginx pgsql grafana docker compose

Topics

Resources

Stars

76 stars

Watchers

4 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

Repository files navigation

Zabbix NGINX PostgreSQL + Grafana

Simplified Docker Compose configuration for running Zabbix monitoring system with Grafana dashboards

Architecture Scheme

For those who are used to using zabbix to collect metrics, but want to start drawing dashboards more beautifully

Example simple docker-compose service

Current versions:

  • Zabbix Server: 7.4
  • PostgreSQL: 18-alpine
  • Grafana: 13.2

Image tags live in .env and float within a major version. Run docker compose pull before docker compose up -d to actually pick up patch releases — a floating tag that is already cached locally is reused as-is. PostgreSQL 18 requires Zabbix 7.4.4 or newer.

Quick Start

1. Clone Repository

git clone https://github.com/akmalovaa/zabbix-docker.git
cd zabbix-docker

2. Configure Environment (Optional)

Review and modify the .env file if needed:

cp .env .env.local  # Optional: create local copy
nano .env           # Edit configuration

3. Start Services

docker compose up -d

⏱️ First launch takes 1-2 minutes while PostgreSQL initializes and Zabbix server starts.

4. Verify Installation

Check if all services are running:

docker compose ps

Configuration

Environment Variables

Key variables in .env file:

Variable Default Description
POSTGRES_USER zabbix PostgreSQL username
POSTGRES_PASSWORD zabbix PostgreSQL password
POSTGRES_DB zabbix Database name
GRAFANA_USER admin Grafana admin username (becomes GF_SECURITY_ADMIN_USER)
GRAFANA_SECRET 12345 Grafana admin password (becomes GF_SECURITY_ADMIN_PASSWORD)
ZABBIX_API_USER Admin Zabbix account the Grafana datasource logs in with
ZABBIX_API_PASSWORD zabbix Password for that account
TZ Asia/Yekaterinburg Timezone for all services

⚠️ Security Note: Change default passwords in production!

Services & Ports

Service Internal Port External Port URL
Zabbix Frontend 8080 8080 YOUR_HOST:8080
Grafana 3000 3000 YOUR_HOST:3000
Zabbix Agent 10050 10050 (used internally)
Zabbix Server 10051 10051 (used internally)
PostgreSQL 5432 5432 Published on the host - drop the mapping in compose.yaml to keep it internal
zabbix-init - - One-shot, exits after configuring the agent interface

Usage

Zabbix Web Interface

URL: localhost:8080

Default Credentials:

  • Username: Admin
  • Password: zabbix

Zabbix Agent Connection

Nothing to do - the zabbix-init one-shot service handles this on docker compose up -d.

The bundled Zabbix server host ships from the schema import with a hardcoded 127.0.0.1 agent interface, which inside Docker points at the server container's own loopback instead of the agent. Every agent item then fails with Cannot establish TCP connection to [[127.0.0.1]:10050]. On startup zabbix-init calls the Zabbix API and repoints that interface at the DNS name zabbix-agent. It is idempotent, so it is a no-op on every subsequent start.

The Zabbix server caches host configuration, so metrics start arriving within a minute. To avoid the wait:

docker compose exec zabbix-server zabbix_server -R config_cache_reload
Doing it by hand instead
  1. Navigate to Data collection → Hosts
  2. Click on Zabbix server host
  3. Go to Interfaces tab
  4. Change Connect to from IP to DNS
  5. Set DNS name to zabbix-agent
  6. Update the host

Zabbix Agent Settings Zabbix Agent Check

Grafana Dashboard

URL: localhost:3000

Default Credentials:

  • Username: admin
  • Password: 12345

💡 Anonymous access is enabled by default (see grafana/grafana.ini)

Test Zabbix Data Source

  1. Go to Connections → Data sources
  2. Select Zabbix data source
  3. Click Test button
  4. Should show "Data source is working"

Data Source Test

Troubleshooting

Check Service Logs

# All services
docker compose logs --tail=10 -f

# Specific service
docker compose logs -f zabbix-server
docker compose logs -f postgres

Common Issues

1. Zabbix Server Won't Start

# Check database connection
docker compose logs zabbix-server

# Restart services in order
docker compose restart postgres
sleep 30
docker compose restart zabbix-server

2. Can't Access Web Interface

# Check if ports are available
netstat -tulpn | grep -E ':(8080|3000|10051|10050)'

# Check container status
docker compose ps

3. Grafana Data Source Connection Failed

# Verify Zabbix API is accessible
curl -X POST http://localhost:8080/api_jsonrpc.php \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"apiinfo.version","id":1}'

Performance Tuning

For better performance with large datasets:

# Add to zabbix-server environment in compose.yaml
ZBX_CACHESIZE: "128M"
ZBX_CACHEUPDATEFREQUENCY: "60"
ZBX_STARTDBSYNCERS: "4"

Security Considerations

Production Deployment Checklist

  • Change default passwords in .env
  • Use strong database passwords
  • Restrict access to ports (use firewall/security groups)
  • Enable HTTPS for Zabbix frontend
  • Configure proper backup strategy

References

About

zabbix nginx pgsql grafana docker compose

Topics

Resources

Stars

76 stars

Watchers

4 watching

Forks

Contributors

Languages