You are a senior Java + DevOps engineer.
Create a production-style learning project for understanding centralized logging with Spring Boot, Docker, Kubernetes, and ELK Stack.
Project Goal: Build a backend application that generates structured logs, containerize it with Docker, deploy it to Kubernetes, and integrate it with ELK stack for centralized logging and observability.
Tech Stack:
- Java 21
- Spring Boot 3
- Maven
- Logback
- SLF4J
- logstash-logback-encoder
- Docker
- Kubernetes
- Elasticsearch
- Kibana
- Filebeat
Project Requirements:
- Spring Boot Application Create a REST API project named: order-service
Endpoints:
- POST /orders
- GET /orders/{id}
- DELETE /orders/{id}
- GET /health
- GET /error-test
Requirements:
-
Use layered architecture:
- controller
- service
- repository
- model
- dto
- config
- exception
-
Use in-memory storage initially.
-
Return JSON responses.
-
Add global exception handling.
- Structured Logging Implement production-style structured JSON logging.
Requirements:
- Use logback-spring.xml
- Use LogstashEncoder
- All logs must go to stdout
- Include:
- timestamp
- log level
- service name
- traceId
- request path
- HTTP method
- message
- exception stack trace
Add:
- request logging filter/interceptor
- correlation ID / traceId generation
- MDC usage
Example log: { "timestamp":"2026-01-01T10:00:00", "level":"INFO", "service":"order-service", "traceId":"abc123", "method":"POST", "path":"/orders", "message":"Order created successfully" }
- Error Simulation Create endpoints that intentionally generate:
- RuntimeException
- validation errors
- 404 errors
Log all exceptions in structured JSON format.
- Dockerization Create:
- optimized Dockerfile
- .dockerignore
Requirements:
- Use eclipse-temurin:21-jre
- Small image size
- Proper layering
- Expose port 8080
Provide commands:
- mvn clean package
- docker build
- docker run
- Docker Compose Environment Create docker-compose.yml containing:
- order-service
- Elasticsearch
- Kibana
Requirements:
- Proper networking
- Environment variables
- Volume mappings
- Health checks
Expose:
- Kibana on 5601
- Elasticsearch on 9200
- Application on 8080
- Kubernetes Deployment Create complete Kubernetes manifests:
- namespace.yaml
- deployment.yaml
- service.yaml
- configmap.yaml
Requirements:
- 2 replicas
- readiness probe
- liveness probe
- resource requests/limits
- environment variables
- labels/selectors
- Filebeat Integration Create Filebeat configuration for Kubernetes.
Requirements:
- DaemonSet deployment
- Collect container stdout logs
- Parse JSON logs
- Send logs to Elasticsearch
- Add Kubernetes metadata
Provide:
- filebeat.yml
- filebeat-daemonset.yaml
- Kibana Explain:
- how to create index patterns
- how to search logs
- how to filter by traceId
- how to create dashboards
Create examples for:
- error rate visualization
- request count visualization
- pod-based filtering
- Observability Concepts Document:
- centralized logging
- stdout logging in containers
- Kubernetes logging architecture
- why JSON logging matters
- correlation IDs
- log aggregation
-
Project Structure Generate a clean professional folder structure.
-
README.md Create a complete README including:
- local development
- Docker usage
- Kubernetes deployment
- ELK setup
- troubleshooting
- useful kubectl commands
- useful docker commands
- Best Practices Apply:
- production logging practices
- clean architecture
- environment-based configuration
- secure defaults
- container best practices
- Kubernetes best practices
- Output Format Generate:
- full source code
- all YAML files
- all Docker files
- all configs
- all commands
- explanations for every important step
The project should be educational, production-inspired, and suitable for a DevOps engineer learning ELK and Kubernetes logging architecture.