Skip to content

Commit eb3c571

Browse files
rikukissaeuanmillar
authored andcommitted
Deploy more logstash and apm-server replicas (#3784)
* deploy more logstash and apm-server replicas, use logstash output for all services including dependencies * add restart: always for apm-server * simplify 7-day-default ILM config so it always deletes records after 7 days or 300mb * make apm-rollover-7-days policy delete its data after 7 days * add default for number of replicates for indexes as 1 * move replica settings to init script as 7.x doesn't support it in .yml file * add logAlias to kibana config * only deploy 2 instances of apm-server and logstash
1 parent 8c11f91 commit eb3c571

File tree

7 files changed

+594
-17
lines changed

7 files changed

+594
-17
lines changed

docker-compose.deploy.yml

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ services:
3131
- node.role == manager
3232
networks:
3333
- overlay_net
34-
34+
logging:
35+
driver: gelf
36+
options:
37+
gelf-address: 'udp://127.0.0.1:12201'
38+
tag: 'traefik'
3539
metricbeat:
3640
image: docker.elastic.co/beats/metricbeat:7.17.0
3741

@@ -62,7 +66,11 @@ services:
6266
target: /usr/share/metricbeat/metricbeat.yml
6367
- source: metricbeat-rollover-policy.{{ts}}
6468
target: /usr/share/metricbeat/rollover-policy.json
65-
69+
logging:
70+
driver: gelf
71+
options:
72+
gelf-address: 'udp://127.0.0.1:12201'
73+
tag: 'metricbeat'
6674
setup-kibana-config:
6775
image: curlimages/curl:7.83.1
6876
entrypoint:
@@ -90,7 +98,11 @@ services:
9098
placement:
9199
constraints:
92100
- node.role == manager
93-
101+
logging:
102+
driver: gelf
103+
options:
104+
gelf-address: 'udp://127.0.0.1:12201'
105+
tag: 'setup-kibana-config'
94106
kibana:
95107
image: docker.elastic.co/kibana/kibana:7.17.0
96108
restart: always
@@ -114,7 +126,11 @@ services:
114126
target: /usr/share/kibana/config/kibana.yml
115127
depends_on:
116128
- elasticsearch
117-
129+
logging:
130+
driver: gelf
131+
options:
132+
gelf-address: 'udp://127.0.0.1:12201'
133+
tag: 'kibana'
118134
# Configure mongo nodes as a replica set
119135
mongo1:
120136
command: mongod --auth --replSet rs0 --keyFile /etc/mongodb-keyfile
@@ -150,7 +166,11 @@ services:
150166
target: /docker-entrypoint-initdb.d/create-mongo-users.sh
151167
networks:
152168
- overlay_net
153-
169+
logging:
170+
driver: gelf
171+
options:
172+
gelf-address: 'udp://127.0.0.1:12201'
173+
tag: 'mongo1'
154174
mongo-on-update:
155175
image: mongo:4.4
156176
command: bash /on-deploy.sh
@@ -174,12 +194,20 @@ services:
174194
- WEBHOOKS_MONGODB_PASSWORD=${WEBHOOKS_MONGODB_PASSWORD}
175195
networks:
176196
- overlay_net
177-
197+
logging:
198+
driver: gelf
199+
options:
200+
gelf-address: 'udp://127.0.0.1:12201'
201+
tag: 'mongo-on-update'
178202
# Configure redis
179203
redis:
180204
networks:
181205
- overlay_net
182-
206+
logging:
207+
driver: gelf
208+
options:
209+
gelf-address: 'udp://127.0.0.1:12201'
210+
tag: 'redis'
183211
# Configure elasticsearch
184212
elasticsearch:
185213
volumes:
@@ -203,10 +231,15 @@ services:
203231
- 9200:9200
204232
networks:
205233
- overlay_net
234+
logging:
235+
driver: gelf
236+
options:
237+
gelf-address: 'udp://127.0.0.1:12201'
238+
tag: 'elasticsearch'
206239

207240
setup-elasticsearch-users:
208241
image: ubuntu:bionic
209-
entrypoint: ['bash', '/usr/app/setup-users.sh']
242+
entrypoint: ['bash', '/usr/app/setup.sh']
210243
restart: on-failure
211244
depends_on:
212245
- elasticsearch
@@ -228,6 +261,11 @@ services:
228261
placement:
229262
constraints:
230263
- node.role == manager
264+
logging:
265+
driver: gelf
266+
options:
267+
gelf-address: 'udp://127.0.0.1:12201'
268+
tag: 'setup-elasticsearch-users'
231269
elastalert:
232270
image: jertel/elastalert2:2.3.0
233271
restart: unless-stopped
@@ -241,6 +279,11 @@ services:
241279
placement:
242280
constraints:
243281
- node.role == manager
282+
logging:
283+
driver: gelf
284+
options:
285+
gelf-address: 'udp://127.0.0.1:12201'
286+
tag: 'elastalert'
244287

245288
logstash:
246289
image: logstash:7.17.0
@@ -263,13 +306,16 @@ services:
263306
networks:
264307
- overlay_net
265308
restart: always
309+
deploy:
310+
replicas: 2
266311
apm-server:
267312
image: docker.elastic.co/apm/apm-server:7.15.2
268313
depends_on:
269314
- elasticsearch
270315
- kibana
271316
cap_add: ['CHOWN', 'DAC_OVERRIDE', 'SETGID', 'SETUID']
272317
cap_drop: ['ALL']
318+
restart: always
273319
ports:
274320
- 8200:8200
275321
networks:
@@ -294,7 +340,11 @@ services:
294340
configs:
295341
- source: apm.{{ts}}
296342
target: /usr/share/apm-server/apm-server.yml
297-
343+
logging:
344+
driver: gelf
345+
options:
346+
gelf-address: 'udp://127.0.0.1:12201'
347+
tag: 'apm-server'
298348
# Configure influxdb
299349
influxdb:
300350
volumes:
@@ -307,7 +357,11 @@ services:
307357
- node.labels.data1 == true
308358
networks:
309359
- overlay_net
310-
360+
logging:
361+
driver: gelf
362+
options:
363+
gelf-address: 'udp://127.0.0.1:12201'
364+
tag: 'influxdb'
311365
# Configure webapps and add traefik config
312366
client:
313367
environment:

infrastructure/elasticsearch/setup-helpers.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,36 @@ function ensure_role {
198198
echo -e "\n${output::-3}\n"
199199
fi
200200

201+
return $result
202+
}
203+
204+
function ensure_settings {
205+
local body=$1
206+
207+
local elasticsearch_host="${ELASTICSEARCH_HOST:-elasticsearch}"
208+
209+
local -a args=( '-s' '-D-' '-m15' '-w' '%{http_code}'
210+
"http://${elasticsearch_host}:9200/_settings"
211+
'-X' 'PUT'
212+
'-H' 'Content-Type: application/json'
213+
'-d' "$body"
214+
)
215+
216+
if [[ -n "${ELASTIC_PASSWORD:-}" ]]; then
217+
args+=( '-u' "elastic:${ELASTIC_PASSWORD}" )
218+
fi
219+
220+
local -i result=1
221+
local output
222+
223+
output="$(curl "${args[@]}")"
224+
if [[ "${output: -3}" -eq 200 ]]; then
225+
result=0
226+
fi
227+
228+
if ((result)); then
229+
echo -e "\n${output::-3}\n"
230+
fi
231+
201232
return $result
202233
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
6+
#
7+
# OpenCRVS is also distributed under the terms of the Civil Registration
8+
# & Healthcare Disclaimer located at http://opencrvs.org/license.
9+
#
10+
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
11+
# graphic logo are (registered/a) trademark(s) of Plan International.
12+
13+
set -eu
14+
set -o pipefail
15+
16+
source "$(dirname "${BASH_SOURCE[0]}")/setup-helpers.sh"
17+
18+
echo "-------- $(date) --------"
19+
20+
log 'Waiting for availability of Elasticsearch'
21+
wait_for_elasticsearch
22+
23+
ensure_settings "{\"index\":{\"number_of_replicas\":0}}"

infrastructure/elasticsearch/setup-users.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
set -eu
1414
set -o pipefail
1515

16-
apt-get update
17-
apt-get install curl -y
18-
1916
source "$(dirname "${BASH_SOURCE[0]}")/setup-helpers.sh"
2017

2118

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
6+
#
7+
# OpenCRVS is also distributed under the terms of the Civil Registration
8+
# & Healthcare Disclaimer located at http://opencrvs.org/license.
9+
#
10+
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
11+
# graphic logo are (registered/a) trademark(s) of Plan International.
12+
13+
set -eu
14+
set -o pipefail
15+
16+
apt-get update
17+
apt-get install curl -y
18+
19+
bash "$(dirname "${BASH_SOURCE[0]}")/setup-users.sh"
20+
bash "$(dirname "${BASH_SOURCE[0]}")/setup-settings.sh"
21+
22+
23+

infrastructure/monitoring/kibana/config.ndjson

Lines changed: 452 additions & 4 deletions
Large diffs are not rendered by default.

infrastructure/monitoring/kibana/kibana.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ monitoring.ui.container.elasticsearch.enabled: true
5454
xpack.encryptedSavedObjects.encryptionKey: '{{KIBANA_ENCRYPTION_KEY}}'
5555
xpack.reporting.encryptionKey: '{{KIBANA_ENCRYPTION_KEY}}'
5656
xpack.actions.preconfiguredAlertHistoryEsIndex: true
57+
xpack.infra.sources.default.logAlias: 'logs-*,filebeat-*,kibana_sample_data_logs*,logstash*'
5758
# If your Elasticsearch is protected with basic authentication, these settings provide
5859
# the username and password that the Kibana server uses to perform maintenance on the Kibana
5960
# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which

0 commit comments

Comments
 (0)