A full-stack infrastructure monitoring solution using Docker Compose that includes a Spring Boot application, PostgreSQL with replication, HAProxy load balancer, ELK stack for logging, and Prometheus + Grafana for metrics monitoring.
┌─────────────┐
│ HAProxy │ :8088
│ Load Balancer│
└──────┬──────┘
┌──────────┴──────────┐
▼ ▼
┌────────────┐ ┌────────────┐
│ Tomcat 1 │ │ Tomcat 2 │
│ :8082 │ │ :8083 │
└─────┬──────┘ └─────┬──────┘
└──────────┬──────────┘
▼
┌───────────┐
│ PgPool │ :9999
└─────┬─────┘
┌──────────┴──────────┐
▼ ▼
┌──────────────┐ ┌──────────────────┐
│ PostgreSQL │ │ PostgreSQL │
│ Primary │────▶│ Replica │
│ :5432 │ │ :5432 │
└──────────────┘ └──────────────────┘
┌─────────────────────────────────────────────────────────┐
│ MONITORING STACK │
│ │
│ Node Exporter → Prometheus → Grafana │
│ :9100 :9090 :3000 │
│ │
│ HAProxy Exporter → Prometheus │
│ :9101 │
│ │
│ rsyslog → Elasticsearch → Kibana │
│ :514 :9200 :5601 │
└─────────────────────────────────────────────────────────┘
| Component | Technology | Port |
|---|---|---|
| Application | Spring Boot 3.x + Tomcat 10 | 8082, 8083 |
| Load Balancer | HAProxy | 8088 |
| Database Primary | PostgreSQL 16 | 5432 |
| Database Replica | PostgreSQL 16 (Streaming Replication) | 5432 |
| Connection Pooling | PgPool 4.6 | 9999 |
| Metrics Collection | Prometheus | 9090 |
| Metrics Visualization | Grafana | 3000 |
| Node Metrics | Node Exporter | 9100 |
| HAProxy Metrics | HAProxy Exporter | 9101 |
| Log Collection | rsyslog | 514 |
| Log Storage | Elasticsearch 8.14 | 9200 |
| Log Visualization | Kibana 8.14 | 5601 |
infra-monitoring-project/
├── docker-compose.yml
├── README.md
│
├── app/
│ └── employee-app/
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/com/company/employeeapp/
│ │ ├── controller/
│ │ ├── entity/
│ │ ├── repository/
│ │ └── service/
│ ├── resources/
│ │ └── application.properties
│ └── webapp/
│ └── WEB-INF/jsp/
│
├── config/
│ ├── Dockerfile.rsyslog
│ └── rsyslog.conf
│
├── haproxy/
│ └── haproxy.cfg
│
└── prometheus/
└── prometheus.yml
- Docker & Docker Compose installed
- Java 21 + Maven (for building the app)
- Minimum 8GB RAM recommended
git clone https://github.com/<your-username>/infra-monitoring-project.git
cd infra-monitoring-projectcd app/employee-app
mvn clean package -DskipTests -Dspring-boot.repackage.skip=true
cd ../..docker-compose up -d --builddocker psExpected containers:
postgres-primary
postgres-replica
pgpool
tomcat1
tomcat2
haproxy
haproxy-exporter
prometheus
grafana
node-exporter
rsyslog
elasticsearch
kibana
| Service | URL | Credentials |
|---|---|---|
| Application | http://localhost:8088 | - |
| Tomcat 1 (direct) | http://localhost:8082 | - |
| Tomcat 2 (direct) | http://localhost:8083 | - |
| HAProxy Stats | http://localhost:8404/stats | - |
| Prometheus | http://localhost:9090 | - |
| Grafana | http://localhost:3000 | admin / admin |
| Kibana | http://localhost:5601 | - |
| Elasticsearch | http://localhost:9200 | - |
| Node Exporter | http://localhost:9100/metrics | - |
| PgPool | localhost:9999 | admin / admin123 |
Grafana → Configuration → Data Sources → Add data source
Type: Prometheus
URL: http://prometheus:9090
Save & Test
Grafana → Dashboards → Import
Upload: grafana-dashboard.json
Select Prometheus datasource → Import
Dashboard includes:
- ✅ CPU Utilisation (Gauge + Time Series)
- ✅ RAM Usage (Gauge + Detailed breakdown)
- ✅ Disk Usage (Gauge + I/O)
- ✅ Network Traffic (In/Out)
- ✅ System Load Average (1m/5m/15m)
- ✅ System Info (Uptime, Cores, Total RAM, Disk)
Kibana → Stack Management → Data Views → Create data view
Name: syslog
Index pattern: syslog*
Timestamp field: timestamp
Save
Kibana → Discover → Select "syslog" → Set time range
# Single log
logger -n 127.0.0.1 -P 514 --udp "Test message"
# Continuous log generation
while true; do
logger -n 127.0.0.1 -P 514 --udp "[INFO] Service health check OK at $(date)"
logger -n 127.0.0.1 -P 514 --udp "[ERROR] Connection timeout at $(date)"
sleep 2
doneHost: localhost:9999 (via PgPool)
Database: employeedb
Username: admin
Password: admin123
docker exec postgres-primary psql -U admin -c "SELECT * FROM pg_stat_replication;"docker exec pgpool psql -h localhost -U admin -p 5432 -c "SHOW pool_nodes;" employeedbAccess: http://localhost:9090/targets
| Job | Target | Status |
|---|---|---|
| node-exporter | node-exporter:9100 | ✅ UP |
| haproxy | haproxy-exporter:9101 | ✅ UP |
| postgres-primary | postgres-exporter-primary:9187 | ✅ UP |
| postgres-replica | postgres-exporter-replica:9187 | ✅ UP |
# View all container logs
docker-compose logs -f
# View specific container logs
docker logs <container-name> --tail 50
# Restart a service
docker-compose restart <service-name>
# Stop all services
docker-compose down
# Stop and remove volumes
docker-compose down -v
# Check Elasticsearch indices
curl http://localhost:9200/_cat/indices?v
# Check log count
curl http://localhost:9200/syslog/_count
# Check HAProxy stats via curl
curl http://localhost:8404/statsCollects system logs and forwards to Elasticsearch via omelasticsearch plugin.
Load balances traffic between Tomcat1 and Tomcat2 with health checks.
Scrapes metrics from Node Exporter, HAProxy Exporter, and Postgres Exporters every 15 seconds.
Spring Boot app connects to PostgreSQL via PgPool with Actuator and Prometheus metrics enabled.
docker logs rsyslog --tail 20
docker exec rsyslog curl -s http://elasticsearch:9200/_cat/healthdocker logs tomcat1 --tail 30docker logs postgres-replica --tail 20
docker exec postgres-primary psql -U admin -c "SELECT * FROM pg_stat_replication;"curl http://localhost:9090/targets
docker logs prometheus --tail 20Sonu
Infrastructure Monitoring Project
Built with ❤️ using Docker, Spring Boot, ELK Stack, and Prometheus