Skip to content

Commit 50d9db6

Browse files
Merge pull request #127 from sherifabdlnaby/upgrade-9
Upgrade to ELK v9!
2 parents 64326a5 + 46ef7ed commit 50d9db6

17 files changed

Lines changed: 380 additions & 148 deletions

File tree

.env

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
COMPOSE_PROJECT_NAME=elastic
2-
ELK_VERSION=8.10.2
2+
ELK_VERSION=9.2.3
33

44
#----------- Images to use ----------------------#
55

@@ -9,9 +9,10 @@ LOGSTASH_IMAGE_NAME=elastdocker/logstash
99
KIBANA_IMAGE_NAME=elastdocker/kibana
1010
APM_SERVER_IMAGE_NAME=elastdocker/apm-server
1111
FILEBEAT_IMAGE_NAME=docker.elastic.co/beats/filebeat
12+
METRICBEAT_IMAGE_NAME=docker.elastic.co/beats/metricbeat
1213

1314
# the following images will be used as is
14-
ELASTICSEARCH_EXPORTER_IMAGE=justwatch/elasticsearch_exporter:1.1.0
15+
ELASTICSEARCH_EXPORTER_IMAGE=quay.io/prometheuscommunity/elasticsearch-exporter:v1.10.0
1516
LOGSTASH_EXPORTER_IMAGE=alxrem/prometheus-logstash-exporter
1617

1718
#----------- Resources --------------------------#

Makefile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@ COMPOSE_LOGGING := -f docker-compose.yml -f docker-compose.logs.yml
88
COMPOSE_NODES := -f docker-compose.yml -f docker-compose.nodes.yml
99
ELK_SERVICES := elasticsearch logstash kibana apm-server
1010
ELK_LOG_COLLECTION := filebeat
11-
ELK_MONITORING := elasticsearch-exporter logstash-exporter filebeat-cluster-logs
11+
ELK_MONITORING := elasticsearch-exporter logstash-exporter filebeat-cluster-logs metricbeat
1212
ELK_NODES := elasticsearch-1 elasticsearch-2
1313
ELK_MAIN_SERVICES := ${ELK_SERVICES} ${ELK_MONITORING}
1414
ELK_ALL_SERVICES := ${ELK_MAIN_SERVICES} ${ELK_NODES} ${ELK_LOG_COLLECTION}
1515

16-
compose_v2_not_supported = $(shell command docker compose 2> /dev/null)
17-
ifeq (,$(compose_v2_not_supported))
18-
DOCKER_COMPOSE_COMMAND = docker-compose
19-
else
20-
DOCKER_COMPOSE_COMMAND = docker compose
21-
endif
16+
DOCKER_COMPOSE_COMMAND = docker compose
2217

2318
# --------------------------
2419
.PHONY: setup keystore certs all elk monitoring build down stop restart rm logs
@@ -84,8 +79,9 @@ images: ## Show all Images of ELK and all its extra components.
8479

8580
prune: ## Remove ELK Containers and Delete ELK-related Volume Data (the elastic_elasticsearch-data volume)
8681
@make stop && make rm
87-
@docker volume prune -f --filter label=com.docker.compose.project=${COMPOSE_PROJECT_NAME}
82+
@docker volume ls --filter label=com.docker.compose.project=${COMPOSE_PROJECT_NAME} --format "{{.Name}}" | xargs docker volume rm 2>/dev/null || true
83+
@echo "Removed all volumes for project: ${COMPOSE_PROJECT_NAME}"
8884

8985
help: ## Show this help.
90-
@echo "Make Application Docker Images and Containers using Docker-Compose files in 'docker' Dir."
86+
@echo "Make Application Docker Images and Containers using Docker Compose (v2) files."
9187
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

README.md

Lines changed: 141 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
<h4 align="center">Configured to be ready to be used for Log, Metrics, APM, Alerting, Machine Learning, and Security (SIEM) usecases.</h4>
77
<p align="center">
88
<a>
9-
<img src="https://img.shields.io/badge/Elastic%20Stack-8.10.2-blue?style=flat&logo=elasticsearch" alt="Elastic Stack Version 7^^">
9+
<img src="https://img.shields.io/badge/Elastic%20Stack-9.2.3-blue?style=flat&logo=elasticsearch" alt="Elastic Stack Version 9^^">
1010
</a>
1111
<a>
1212
<img src="https://img.shields.io/github/v/tag/sherifabdlnaby/elastdocker?label=release&amp;sort=semver">
1313
</a>
1414
<a href="https://github.com/sherifabdlnaby/elastdocker/actions/workflows/build.yml">
1515
<img src="https://github.com/sherifabdlnaby/elastdocker/actions/workflows/build.yml/badge.svg">
1616
</a>
17-
<a>
18-
<img src="https://img.shields.io/badge/Log4Shell-mitigated-brightgreen?style=flat&logo=java">
19-
</a>
2017
<a>
2118
<img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="contributions welcome">
2219
</a>
@@ -36,8 +33,11 @@ Elastic Stack (**ELK**) Docker Composition, preconfigured with **Security**, **M
3633

3734
Suitable for Demoing, MVPs and small production deployments.
3835

39-
Stack Version: [8.10.2](https://www.elastic.co/blog/whats-new-elastic-8-10-0) 🎉 - Based on [Official Elastic Docker Images](https://www.docker.elastic.co/)
40-
> You can change Elastic Stack version by setting `ELK_VERSION` in `.env` file and rebuild your images. Any version >= 8.0.0 is compatible with this template.
36+
Stack Version: [9.2.3](https://www.elastic.co/guide/en/elasticsearch/reference/9.2/release-notes-9.2.3.html) 🎉 - Based on [Official Elastic Docker Images](https://www.docker.elastic.co/)
37+
> You can change Elastic Stack version by setting `ELK_VERSION` in `.env` file and rebuild your images. Any version >= 9.0.0 is compatible with this template.
38+
>
39+
> ⚠️ **Upgrading from 8.x?** See the [Upgrade Notes](#upgrade-notes-from-8x-to-9x) section below for breaking changes and migration steps.
40+
---
4141

4242
### Main Features 📜
4343

@@ -52,9 +52,9 @@ Stack Version: [8.10.2](https://www.elastic.co/blog/whats-new-elastic-8-10-0)
5252
- Anomaly Detection
5353
- SIEM (Security information and event management).
5454
- Enabling Trial License
55-
- Use Docker-Compose and `.env` to configure your entire stack parameters.
55+
- Use Docker Compose and `.env` to configure your entire stack parameters.
5656
- Persist Elasticsearch's Keystore and SSL Certifications.
57-
- Self-Monitoring Metrics Enabled.
57+
- Self-Monitoring Metrics Enabled (using Metricbeat for ES 9+).
5858
- Prometheus Exporters for Stack Metrics.
5959
- Embedded Container Healthchecks for Stack Images.
6060

@@ -79,7 +79,7 @@ Elastdocker differs from `deviantony/docker-elk` in the following points.
7979

8080
- Parameterize all other Config like Heap Size.
8181

82-
- Add recommended environment configurations as Ulimits and Swap disable to the docker-compose.
82+
- Add recommended environment configurations as Ulimits and Swap disable to Docker Compose.
8383

8484
- Make it ready to be extended into a multinode cluster.
8585

@@ -92,12 +92,23 @@ Elastdocker differs from `deviantony/docker-elk` in the following points.
9292
</p>
9393
</details>
9494

95+
96+
### Automatic Docker Container Log Collection
97+
98+
Collect logs from **all Docker containers** on your host with a single command:
99+
100+
```bash
101+
make collect-docker-logs
102+
```
103+
104+
Filebeat automatically discovers containers, parses logs, and ships them to Elasticsearch. View and analyze everything in Kibana with zero configuration.
105+
106+
95107
-----
96108

97109
# Requirements
98110

99-
- [Docker 20.05 or higher](https://docs.docker.com/install/)
100-
- [Docker-Compose 1.29 or higher](https://docs.docker.com/compose/install/)
111+
- [Docker 20.05 or higher](https://docs.docker.com/install/) with Docker Compose v2
101112
- 4GB RAM (For Windows and MacOS make sure Docker's VM has more than 4GB+ memory.)
102113

103114
# Setup
@@ -113,7 +124,7 @@ Elastdocker differs from `deviantony/docker-elk` in the following points.
113124
> **For Linux's docker hosts only**. By default virtual memory [is not enough](https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html) so run the next command as root `sysctl -w vm.max_map_count=262144`
114125
3. Start Elastic Stack
115126
```bash
116-
$ make elk <OR> $ docker-compose up -d <OR> $ docker compose up -d
127+
$ make elk <OR> $ docker compose up -d
117128
```
118129
4. Visit Kibana at [https://localhost:5601](https://localhost:5601) or `https://<your_public_ip>:5601`
119130
@@ -168,14 +179,15 @@ $ make prune
168179

169180
* Some Configuration are parameterized in the `.env` file.
170181
* `ELASTIC_PASSWORD`, user `elastic`'s password (default: `changeme` _pls_).
171-
* `ELK_VERSION` Elastic Stack Version (default: `8.10.2`)
182+
* `ELK_VERSION` Elastic Stack Version (default: `9.2.3`)
172183
* `ELASTICSEARCH_HEAP`, how much Elasticsearch allocate from memory (default: 1GB -good for development only-)
173184
* `LOGSTASH_HEAP`, how much Logstash allocate from memory.
174185
* Other configurations which their such as cluster name, and node name, etc.
175186
* Elasticsearch Configuration in `elasticsearch.yml` at `./elasticsearch/config`.
176187
* Logstash Configuration in `logstash.yml` at `./logstash/config/logstash.yml`.
177188
* Logstash Pipeline in `main.conf` at `./logstash/pipeline/main.conf`.
178189
* Kibana Configuration in `kibana.yml` at `./kibana/config`.
190+
* Metricbeat Configuration in `metricbeat.yml` at `./metricbeat/config` (for Stack Monitoring in ES 9+).
179191

180192
### Setting Up Keystore
181193

@@ -193,7 +205,7 @@ make keystore
193205

194206
- Adding Two Extra Nodes to the cluster will make the cluster depending on them and won't start without them again.
195207

196-
- Makefile is a wrapper around `Docker-Compose` commands, use `make help` to know every command.
208+
- Makefile is a wrapper around `Docker Compose` commands, use `make help` to know every command.
197209

198210
- Elasticsearch will save its data to a volume named `elasticsearch-data`
199211

@@ -243,13 +255,19 @@ For more details or other languages you can check the following:
243255
244256
# Monitoring The Cluster
245257
246-
### Via Self-Monitoring
258+
### Via Stack Monitoring (Metricbeat)
259+
260+
**Elasticsearch 9+** uses Metricbeat for Stack Monitoring (the recommended approach). When you start monitoring with `make monitoring`, Metricbeat will collect metrics from all stack components and send them to Elasticsearch.
247261
248-
Head to Stack Monitoring tab in Kibana to see cluster metrics for all stack components.
262+
Head to **Stack Monitoring** tab in Kibana to see cluster metrics for all stack components.
249263
250264
![Overview](https://user-images.githubusercontent.com/16992394/156664539-cc7e1a69-f1aa-4aca-93f6-7aedaabedd2c.png)
251265
![Moniroting](https://user-images.githubusercontent.com/16992394/156664647-78cfe2af-489d-4c35-8963-9b0a46904cf7.png)
252266
267+
**Architecture Change in ES 9:**
268+
- **ES 8.x and earlier**: Used internal `xpack.monitoring` for self-monitoring
269+
- **ES 9.x**: Uses external Metricbeat collection (more scalable and reliable)
270+
253271
> In Production, cluster metrics should be shipped to another dedicated monitoring cluster.
254272
255273
### Via Prometheus Exporters
@@ -260,11 +278,116 @@ If you started Prometheus Exporters using `make monitoring` command. Prometheus
260278
| `elasticsearch-exporter` | `9114` | [Elasticsearch by Kristian Jensen](https://grafana.com/grafana/dashboards/4358) |
261279
| `logstash-exporter` | `9304` | [logstash-monitoring by dpavlos](https://github.com/dpavlos/logstash-monitoring) |
262280
263-
![Metrics](https://user-images.githubusercontent.com/16992394/78685076-89a58900-78f1-11ea-959b-ce374fe51500.jpg)
281+
**Note:** Elasticsearch Exporter uses updated flags for ES 9 compatibility (`--es.indices` instead of deprecated `--collector.indices`).
282+
283+
![Metrics](https://user-images.githubusercontent.com/16992194/78685076-89a58900-78f1-11ea-959b-ce374fe51500.jpg)
284+
285+
---
286+
287+
# Upgrade Notes from 8.x to 9.x
288+
289+
<details><summary>Expand to see breaking changes and migration details...</summary>
290+
<p>
291+
292+
Elasticsearch 9 introduced several breaking changes. This section documents the changes made to ElastDocker for ES 9 compatibility.
293+
294+
## Breaking Changes Fixed
295+
296+
### 1. **Logstash Configuration Changes**
297+
298+
**File: `logstash/config/logstash.yml`**
299+
- `http.host` → `api.http.host`
300+
301+
**File: `logstash/pipeline/main.conf`**
302+
- `ssl` → `ssl_enabled`
303+
- `ssl_certificate_verification` → `ssl_verification_mode`
304+
- `cacert` → `ssl_certificate_authorities`
305+
306+
### 2. **Monitoring Architecture Change**
307+
308+
**Before (ES 8.x):**
309+
- Used internal `xpack.monitoring.collection.enabled` setting
310+
- Components self-reported metrics
311+
312+
**After (ES 9.x):**
313+
- Uses external Metricbeat for metric collection
314+
- More scalable and follows Elastic's recommended approach
315+
- New component: `metricbeat` service in `docker-compose.monitor.yml`
316+
317+
**Files Modified:**
318+
- `elasticsearch/config/elasticsearch.yml` - Removed `xpack.monitoring.collection.enabled`
319+
- `logstash/config/logstash.yml` - Removed `xpack.monitoring` settings
320+
- `apm-server/config/apm-server.yml` - Removed monitoring section
321+
- `metricbeat/config/metricbeat.yml` - **NEW FILE** for Stack Monitoring
322+
323+
### 3. **Filebeat Migration to Filestream Input**
324+
325+
The `container` input type is deprecated in Filebeat 9. Migrated to the modern `filestream` input with container parser - the ES 9+ recommended approach.
326+
327+
**Files Modified:**
328+
- `filebeat/filebeat.docker.logs.yml` - Now uses `type: filestream` with container parser
329+
- `filebeat/filebeat.monitoring.yml` - All module inputs migrated to filestream
330+
331+
**Key Changes:**
332+
- `type: container` → `type: filestream` with unique IDs
333+
- Added `parsers.container` configuration for Docker log parsing
334+
- Added `prospector.scanner.symlinks: true` for Docker log paths
335+
- No deprecation warnings - fully ES 9 compliant
336+
337+
### 4. **Certificate Generation Script**
338+
339+
**File: `setup/setup-certs.sh`**
340+
- Updated password generation to work without `openssl` command (not available in ES 9 containers)
341+
- Now uses `/dev/urandom` for random password generation
342+
343+
### 5. **Elasticsearch Exporter Flags**
344+
345+
**File: `docker-compose.monitor.yml`**
346+
- Updated exporter flags for compatibility with exporter v1.10.0+
347+
- `--collector.indices` → `--es.indices`
348+
349+
## Known Deprecation Warnings
350+
351+
The following deprecation warnings are expected and originate from upstream Elastic components. They will be resolved in future component releases:
352+
353+
1. **Beats using `?local` parameter** (CRITICAL) - ~446 occurrences
354+
- Source: Metricbeat
355+
- Will be fixed in future Beats releases
356+
- **Note:** Filebeat no longer generates these warnings after migrating to filestream input
357+
358+
2. **Behavioral Analytics deprecated** (WARN) - ~37 occurrences
359+
- Source: Kibana cleanup process
360+
- Expected during ES 9 migration
361+
- Will resolve once cleanup completes
362+
363+
3. **APM System Index Access** (WARN) - ~13 occurrences
364+
- Source: APM Server
365+
- Will be fixed in future APM Server releases
366+
367+
These warnings don't affect functionality and are logged to the deprecation data stream for visibility.
368+
369+
## Upgrade Path
370+
371+
**Important:** You must upgrade to Elasticsearch 8.19.x before upgrading to 9.x.
372+
373+
**Recommended Path:**
374+
```
375+
8.17.0 → 8.19.x (run Upgrade Assistant) → 9.x
376+
```
377+
378+
For a clean installation on ES 9, simply:
379+
1. Set `ELK_VERSION=9.2.3` in `.env`
380+
2. Run `make setup`
381+
3. Run `make elk` (or `make all` for full stack with monitoring)
382+
383+
</p>
384+
</details>
385+
386+
---
264387
265388
# License
266389
[MIT License](https://raw.githubusercontent.com/sherifabdlnaby/elastdocker/master/LICENSE)
267-
Copyright (c) 2022 Sherif Abdel-Naby
390+
Copyright (c) 2022-2026 Sherif Abdel-Naby
268391
269392
# Contribution
270393

apm-server/config/apm-server.yml

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -59,43 +59,8 @@ output.elasticsearch:
5959
# Client Certificate Key
6060
ssl.key: "/certs/apm-server.key"
6161

62-
#============================= X-pack Monitoring =============================
62+
#============================= Monitoring =============================
6363

64-
# APM server can export internal metrics to a central Elasticsearch monitoring
65-
# cluster. This requires x-pack monitoring to be enabled in Elasticsearch. The
66-
# reporting is disabled by default.
67-
68-
# Set to true to enable the monitoring reporter.
69-
monitoring.enabled: true
70-
71-
# Most settings from the Elasticsearch output are accepted here as well.
72-
# Note that these settings should be configured to point to your Elasticsearch *monitoring* cluster.
73-
# Any setting that is not set is automatically inherited from the Elasticsearch
74-
# output configuration. This means that if you have the Elasticsearch output configured,
75-
# you can simply uncomment the following line.
76-
monitoring.elasticsearch:
77-
78-
# Protocol - either `http` (default) or `https`.
79-
protocol: "https"
80-
81-
# Authentication credentials
82-
username: '${ELASTIC_USERNAME}'
83-
password: '${ELASTIC_PASSWORD}'
84-
85-
# Array of hosts to connect to.
86-
# Scheme and port can be left out and will be set to the default (`http` and `9200`).
87-
# In case you specify and additional path, the scheme is required: `http://elasticsearch:9200/path`.
88-
# IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`.
89-
hosts: '${ELASTICSEARCH_HOST_PORT}'
90-
91-
# Enable custom SSL settings. Set to false to ignore custom SSL settings for secure communication.
92-
ssl.enabled: true
93-
94-
# List of root certificates for HTTPS server verifications.
95-
ssl.certificate_authorities: ["/certs/ca.crt"]
96-
97-
# Certificate for SSL client authentication.
98-
ssl.certificate: "/certs/apm-server.crt"
99-
100-
# Client Certificate Key
101-
ssl.key: "/certs/apm-server.key"
64+
# ES 9: xpack.monitoring is deprecated
65+
# Stack Monitoring is now handled by Metricbeat (see docker-compose.monitor.yml)
66+
monitoring.enabled: false

docker-compose.logs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.5'
2-
31
# will contain all elasticsearch data.
42
volumes:
53
filebeat-data:

0 commit comments

Comments
 (0)