-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.elastic.yml
312 lines (301 loc) · 11.3 KB
/
docker-compose.elastic.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
---
services:
fleet-server:
image: docker.elastic.co/beats/elastic-agent:${ELASTIC__STACK_VERSION}
restart: unless-stopped
mem_limit: 256M
labels:
co.elastic.logs/enabled: false
co.elastic.metrics/enabled: false
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
kibana_setup:
condition: service_completed_successfully
user: root #/var/run/docker.sock
environment:
FLEET_SERVER_ENABLE: "1"
FLEET_SERVER_POLICY_ID: fleet-server
FLEET_SERVER_ELASTICSEARCH_HOST: http://elasticsearch:9200
FLEET_SERVER_ELASTICSEARCH_USERNAME: elastic
FLEET_SERVER_ELASTICSEARCH_PASSWORD: $ELASTIC__INITIAL_PASSWORD
FLEET_SERVER_INSECURE_HTTP: true
FLEET_SERVER_HOST: "0.0.0.0"
KIBANA_FLEET_SETUP: true
KIBANA_HOST: http://kibana:5601
KIBANA_USERNAME: elastic
KIBANA_PASSWORD: $ELASTIC__INITIAL_PASSWORD
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
container_name: fleet-server
hostname: fleet-server
networks:
- oam
healthcheck:
interval: 10s
retries: 12
test: curl -s http://localhost:8220/api/status | grep -q '"status":"HEALTHY"'
apm:
image: docker.elastic.co/beats/elastic-agent:${ELASTIC__STACK_VERSION}
restart: unless-stopped
mem_limit: 256M
labels:
co.elastic.logs/enabled: false
co.elastic.metrics/enabled: false
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
fleet-server:
condition: service_healthy
user: root #/var/run/docker.sock
environment:
FLEET_ENROLL: 1
FLEET_URL: http://fleet-server:8220
FLEET_INSECURE: true
FLEET_TOKEN_POLICY_NAME: apm
FLEET_TOKEN_NAME: Default
KIBANA_FLEET_HOST: http://kibana:5601
KIBANA_FLEET_USERNAME: elastic
KIBANA_FLEET_PASSWORD: $ELASTIC__INITIAL_PASSWORD
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
ELASTICSEARCH_USERNAME: elastic
ELASTICSEARCH_PASSWORD: $ELASTIC__INITIAL_PASSWORD
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
container_name: apm
hostname: apm
ports:
- 8200:8200
networks:
- oam
healthcheck:
interval: 10s
retries: 12
test: curl -s http://localhost:8200 | grep -q '"publish_ready":\ true'
filebeat:
image: docker.elastic.co/beats/filebeat:${ELASTIC__STACK_VERSION}
restart: unless-stopped
mem_limit: 256M
labels:
co.elastic.logs/enabled: false
co.elastic.metrics/raw: "[{\"module\":\"beat\",\"hosts\":\"filebeat:5066\",\"period\":\"10s\",\"xpack.enabled\":\"true\"}]"
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
user: root #/var/run/docker.sock
entrypoint: []
command: >
bash -c '
filebeat -e \
-E setup.kibana.enabled=true \
-E setup.kibana.host=http://kibana:5601 \
-E setup.dashboards.enabled=true \
-E setup.template.enabled=true \
-E setup.template.settings.index.number_of_replicas=0 \
-E http.enabled=true \
-E http.host=0.0.0.0 \
-E http.port=5066 \
-E monitoring.enabled=false \
-E output.elasticsearch.username=elastic \
-E output.elasticsearch.password=$ELASTIC__INITIAL_PASSWORD \
-E output.elasticsearch.hosts=["http://elasticsearch:9200"] \
-E monitoring.cluster_uuid=$(cat /usr/share/setup/cluster_uuid) \
'
volumes:
- ./elastic/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- elasticsearch_setup:/usr/share/setup:ro
container_name: filebeat
hostname: filebeat
networks:
- oam
healthcheck:
interval: 10s
retries: 12
test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:5066/
metricbeat:
image: docker.elastic.co/beats/metricbeat:${ELASTIC__STACK_VERSION}
restart: unless-stopped
mem_limit: 256M
labels:
co.elastic.logs/enabled: false
co.elastic.metrics/raw: "[{\"module\":\"beat\",\"hosts\":\"metricbeat:5066\",\"period\":\"10s\",\"xpack.enabled\":\"true\"}]"
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
user: root #/var/run/docker.sock
entrypoint: []
command: >
bash -c '
metricbeat -e \
-E setup.kibana.enabled=true \
-E setup.kibana.host=http://kibana:5601 \
-E setup.dashboards.enabled=true \
-E setup.template.enabled=true \
-E setup.template.settings.index.number_of_replicas=0 \
-E http.enabled=true \
-E http.host=0.0.0.0 \
-E http.port=5066 \
-E monitoring.enabled=false \
-E output.elasticsearch.username=elastic \
-E output.elasticsearch.password=$ELASTIC__INITIAL_PASSWORD \
-E output.elasticsearch.hosts=["http://elasticsearch:9200"] \
-E monitoring.cluster_uuid=$(cat /usr/share/setup/cluster_uuid) \
'
volumes:
- ./elastic/metricbeat.yml:/usr/share/metricbeat/metricbeat.yml:ro
- ./elastic/metricbeat/system.yml:/usr/share/metricbeat/modules.d/system.yml
- /var/run/docker.sock:/var/run/docker.sock:ro
- elasticsearch_setup:/usr/share/setup:ro
container_name: metricbeat
hostname: metricbeat
networks:
- oam
healthcheck:
interval: 10s
retries: 12
test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:5066/
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC__STACK_VERSION}
restart: unless-stopped
mem_limit: 5G
labels:
co.elastic.logs/enabled: true
co.elastic.logs/module: elasticsearch
co.elastic.logs/fileset: server
co.elastic.metrics/raw: "[{\"module\":\"elasticsearch\",\"hosts\":\"http://elasticsearch:9200\",\"period\":\"10s\",\"xpack.enabled\":\"true\",\"username\":\"elastic\",\"password\":\"$ELASTIC__INITIAL_PASSWORD\"}]"
environment:
- cluster.name=datacenter
- xpack.license.self_generated.type=trial
- bootstrap.memory_lock=true
- cluster.routing.allocation.disk.threshold_enabled=false
- discovery.type=single-node
- xpack.security.enabled=true
- xpack.security.authc.api_key.enabled=true
- xpack.monitoring.collection.enabled=true
- xpack.monitoring.elasticsearch.collection.enabled=false
- ELASTIC_PASSWORD=$ELASTIC__INITIAL_PASSWORD
- ES_JAVA_OPTS=-Xms4g -Xmx4g
ulimits:
memlock:
hard: -1
soft: -1
volumes:
- esdata:/usr/share/elasticsearch/data
ports:
- 9200:9200
container_name: elasticsearch
hostname: elasticsearch
networks:
- oam
healthcheck:
test: curl -u elastic:$$ELASTIC_PASSWORD -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"'
interval: 20s
retries: 10
elasticsearch_setup:
image: alpine:${ALPINE_VERSION}
user: root #to store cluster_uuid
labels:
co.elastic.logs/enabled: false
co.elastic.metrics/enabled: false
depends_on:
elasticsearch:
condition: service_healthy
command: >
sh -c '
apk add curl;
echo "Waiting for Elasticsearch availability";
until curl -s -u elastic:${ELASTIC__INITIAL_PASSWORD} http://elasticsearch:9200/_cluster/health | grep -vq '"'"'"status":"red"'"'"'; do sleep 30; done;
echo "Setting kibana_system password";
until curl -s -X POST -u elastic:${ELASTIC__INITIAL_PASSWORD} -H "Content-Type: application/json" http://elasticsearch:9200/_security/user/kibana_system/_password -d '"'"'{"password":"${ELASTIC__INITIAL_PASSWORD}"}'"'"' | grep -q "^{}"; do sleep 10; done;
echo "Storing cluster_uuid";
until curl -s -u elastic:${ELASTIC__INITIAL_PASSWORD} http://elasticsearch:9200/ | grep cluster_uuid | awk '"'"'{split($0,a,":"); print a[2]}'"'"' | sed '"'"'s/[\", ]//g'"'"' > /usr/share/setup/cluster_uuid; do sleep 10; done;
echo "All done!";
'
container_name: elasticsearch_setup
volumes:
- elasticsearch_setup:/usr/share/setup
networks:
- oam
kibana:
image: docker.elastic.co/kibana/kibana:${ELASTIC__STACK_VERSION}
restart: unless-stopped
mem_limit: 1G
labels:
co.elastic.logs/enabled: false
co.elastic.logs/module: kibana
co.elastic.logs/fileset: log
co.elastic.metrics/raw: "[{\"module\":\"kibana\",\"hosts\":\"http://kibana:5601\",\"period\":\"10s\",\"xpack.enabled\":\"true\",\"username\":\"kibana_system\",\"password\":\"$ELASTIC__INITIAL_PASSWORD\"}]"
depends_on:
elasticsearch:
condition: service_healthy
elasticsearch_setup:
condition: service_completed_successfully
environment:
ELASTICSEARCH_URL: http://elasticsearch:9200
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
ELASTICSEARCH_USERNAME: kibana_system
ELASTICSEARCH_PASSWORD: $ELASTIC__INITIAL_PASSWORD
XPACK_APM_AUTOCREATEAPMINDEXPATTERN: true
XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: $ELASTIC__ENCRYPTION_KEY
XPACK_SECURITY_ENCRYPTIONKEY: $ELASTIC__ENCRYPTION_KEY
XPACK_REPORTING_ENCRYPTIONKEY: $ELASTIC__ENCRYPTION_KEY
XPACK_FLEET_AGENTS_FLEET_SERVER_HOSTS: '["http://fleet-server:8220"]'
XPACK_FLEET_AGENTS_ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]'
volumes:
- ./elastic/kibana.yml:/usr/share/kibana/config/kibana.yml
- kibanadata:/usr/share/kibana/data
ports:
- 5601:5601
container_name: kibana
hostname: kibana
networks:
- oam
healthcheck:
interval: 10s
retries: 20
test: curl -u kibana_system:$$ELASTICSEARCH_PASSWORD -f -s -o /dev/null http://localhost:5601/api/status
kibana_setup:
image: alpine:${ALPINE_VERSION}
labels:
co.elastic.logs/enabled: false
co.elastic.metrics/enabled: false
depends_on:
kibana:
condition: service_healthy
environment:
ELASTICSEARCH_PASSWORD: $ELASTIC__INITIAL_PASSWORD
command: >
sh -c '
apk add curl;
echo "Waiting for Kibana API availability";
until curl -u kibana_system:$$ELASTICSEARCH_PASSWORD -f -s -o /dev/null http://kibana:5601/api/status; do sleep 30; done;
echo "Update default space";
until curl -s -X PUT -u elastic:${ELASTIC__INITIAL_PASSWORD} -H "Content-Type: application/json" -H "kbn-xsrf: true" http://kibana:5601/api/spaces/space/default -d @/usr/share/setup/spaces/default.json | grep -q "default"; do sleep 10; done;
echo "Update package policies";
until curl -s -X POST -u elastic:${ELASTIC__INITIAL_PASSWORD} -H "Content-Type: application/json" -H "kbn-xsrf: true" http://kibana:5601/api/fleet/package_policies -d @/usr/share/setup/package_policies/cloud-security-posture.json | grep -q "kspm\|already"; do sleep 10; done;
echo "All done!";
'
container_name: kibana_setup
volumes:
- ./elastic/kibana_setup:/usr/share/setup
networks:
- oam
networks:
oam:
volumes:
elasticsearch_setup:
driver: local
esdata:
driver: local
kibanadata:
driver: local