ELK Stack#
The ELK stack β Elasticsearch, Logstash, Kibana β is a mandatory component of the exam's target architecture for the DevOps-Docker final project . It cannot be substituted with alternatives like Loki/Grafana for the primary grading criteria .
Role in the Architecture#
The stack handles centralized log management across all services :
- Logstash collects and transforms logs from the reverse-proxy and application server
- Elasticsearch indexes those logs
- Kibana provides dashboards and search UI, accessible on port 5601
The data flow is: app/proxy β Logstash β Elasticsearch β Kibana.
Minimum Requirements#
The exam spec mandates :
- Logs from both the reverse-proxy and the app server sent to Logstash
- Elasticsearch indexing those logs
- Kibana accessible and showing at least one basic dashboard (volume by service, log table, level filter)
- JSON log format where possible
Docker Compose Integration#
The ELK services must use depends_on / condition: service_healthy to prevent dependent services from starting before ELK is ready . Named volumes are required β anonymous volumes are not accepted :
volumes:
elasticsearch_data:
driver: local
Recommended resource limits :
| Service | CPU Limit | Memory Limit |
|---|---|---|
| Elasticsearch | 2.0 | 2048M |
| Logstash | 1.0 | 1024M |
| Kibana | 1.0 | 512M |
Logstash Configuration#
The canonical input/output pipeline for this architecture :
input {
tcp { port => 5000; codec => json }
}
output {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "app-logs-%{+YYYY.MM.dd}"
}
}
For Java apps, use the LogstashTcpSocketAppender (Logback) to ship logs to logstash:5000.
Elasticsearch Healthcheck#
The basic healthcheck in the exam spec uses a plain HTTP call:
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
β οΈ ES 8+/9+ Compatibility Warning
Starting with Elasticsearch 8.0, security β including TLS and authentication β is enabled by default (release highlights). This means:
http://localhost:9200will return a connection error or redirect; you must usehttps://- The
elasticuser password is auto-generated at first boot
The plain-HTTP healthcheck above will fail silently against an ES 8+/9+ image without additional configuration. Fix options:
- Disable security (dev/exam context only): set
xpack.security.enabled=falsein the ES environment- Adapt the healthcheck to HTTPS with credentials:
test: ["CMD-SHELL", "curl -fs -u elastic:${ELASTIC_PASSWORD} --cacert /usr/share/elasticsearch/config/certs/http_ca.crt https://localhost:9200/_cluster/health || exit 1"]
- Use the bundled
elasticsearch-reset-password/ CLI tools to probe readiness instead of curl
Option 1 is the simplest for local/exam work and pairs withdiscovery.type=single-nodeto avoid cluster bootstrap issues.
Common Pitfall: GELF Logging Address#
A documented exam failure mode: configuring the GELF logging driver with localhost instead of the Logstash service name . localhost inside a container refers only to that container β use the service name instead:
# β WRONG
gelf-address: "udp://localhost:12201"
# β
CORRECT
gelf-address: "udp://logstash:12201"
This error accounts for an average +1.30 point impact on exam scores .
Note: Healthchecks are the one place where
localhostis correct β they run inside the target container itself .
Environment Variables#
The .env.example template includes ELK-specific variables :
ELASTIC_PASSWORD=CHANGEME
KIBANA_PASSWORD=CHANGEME
These must never appear in plaintext in compose.yml.
Primary Sources#
| Resource | Link |
|---|---|
| Exam spec (full ELK requirements) | examen-final-detaille.adoc |
| Networking pitfalls (GELF, localhost) | chapitres/reseaux.adoc |
| Elasticsearch 8.0 security defaults | https://www.elastic.co/guide/en/elasticsearch/reference/8.0/release-highlights.html |
| Official Elasticsearch Docker docs | https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html |