-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdocker-compose.yml.j2
425 lines (415 loc) · 13.3 KB
/
docker-compose.yml.j2
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
version: "3.7"
volumes:
prometheus_data: {}
grafana_data: {}
alertmanager_data: {}
prometheus_data_federation: {}
networks:
monitored:
name: ${MONITORED_NETWORK}
external: true
public:
external: true
name: ${PUBLIC_NETWORK}
configs:
alertmanager_config:
file: ./alertmanager/config.yml
tempo_config:
file: ./tempo_config.yaml
node_exporter_entrypoint:
file: ./node-exporter/docker-entrypoint.sh
prometheus_config:
file: ./prometheus/prometheus.yml
prometheus_config_federation:
file: ./prometheus/prometheus-federation.yml
prometheus_rules:
file: ./prometheus/prometheus.rules.yml
pgsql_query_exporter_config:
file: ./pgsql_query_exporter_config.yaml
smokeping_prober_config:
file: ./smokeping_prober_config.yaml
services:
cadvisor-exporter:
image: gcr.io/cadvisor/cadvisor:v0.49.1
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
networks:
- monitored
command: --logtostderr --docker_only --allow_dynamic_housekeeping=true
deploy:
labels:
- prometheus-job=cadvisor
- prometheus-port=8080
mode: global
resources:
limits:
memory: 256M
cpus: "0.5"
reservations:
memory: 128M
cpus: "0.1"
prometheuscatchall:
hostname: "{% raw %}{{.Service.Name}}{% endraw %}"
image: prom/prometheus:v2.54.0
volumes:
- prometheus_data:/prometheus
- /var/run/docker.sock:/var/run/docker.sock:ro
user: root # only user root can use the docker socket
configs:
- source: prometheus_config
target: /etc/prometheus/prometheus.yml
- source: prometheus_rules
target: /etc/prometheus/prometheus.rules.yml
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention=${MONITORING_PROMETHEUS_RETENTION}"
- "--web.console.libraries=/usr/share/prometheus/console_libraries"
- "--web.console.templates=/usr/share/prometheus/consoles"
- "--web.external-url=https://${MONITORING_DOMAIN}/prometheus/"
- "--web.route-prefix=/"
- "--storage.tsdb.allow-overlapping-blocks" # via https://jessicagreben.medium.com/prometheus-fill-in-data-for-new-recording-rules-30a14ccb8467
#- "--web.enable-admin-api" This allows messing with prometheus using its API from the CLI. Disabled for security reasons by default.
networks:
- monitored
- public
extra_hosts: []
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${PUBLIC_NETWORK}
# direct access through port
- traefik.http.services.prometheuscatchall.loadbalancer.server.port=${MONITORING_PROMETHEUS_PORT}
- traefik.http.routers.prometheuscatchall.rule=Host(`${MONITORING_DOMAIN}`) && PathPrefix(`/prometheus`)
- traefik.http.routers.prometheuscatchall.entrypoints=https
- traefik.http.routers.prometheuscatchall.tls=true
- traefik.http.middlewares.prometheuscatchall_stripprefixregex.stripprefixregex.regex=^/prometheus
- traefik.http.routers.prometheuscatchall.middlewares=ops_whitelist_ips@swarm, ops_auth@swarm, ops_gzip@swarm, prometheuscatchall_stripprefixregex
- prometheus-job=prometheuscatchall
- prometheus-port=${MONITORING_PROMETHEUS_PORT}
resources:
limits:
memory: 4096M
cpus: "2"
reservations:
memory: 2048M
cpus: "0.2"
prometheusfederation:
hostname: "{% raw %}{{.Service.Name}}{% endraw %}"
image: prom/prometheus:v2.54.0
volumes:
- prometheus_data_federation:/prometheus
- /var/run/docker.sock:/var/run/docker.sock:ro
user: root # only user root can use the docker socket
configs:
- source: prometheus_config_federation
target: /etc/prometheus/prometheus.yml
- source: prometheus_rules
target: /etc/prometheus/prometheus.rules.yml
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention=${MONITORING_PROMETHEUS_FEDERATION_RETENTION}"
- "--web.console.libraries=/usr/share/prometheus/console_libraries"
- "--web.console.templates=/usr/share/prometheus/consoles"
- "--web.external-url=https://${MONITORING_DOMAIN}/prometheusfederation/"
- "--web.route-prefix=/"
- "--storage.tsdb.allow-overlapping-blocks" # via https://jessicagreben.medium.com/prometheus-fill-in-data-for-new-recording-rules-30a14ccb8467
#- "--web.enable-admin-api" This allows messing with prometheus using its API from the CLI. Disabled for security reasons by default.
networks:
- monitored
- public
extra_hosts: []
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${PUBLIC_NETWORK}
# direct access through port
- traefik.http.services.prometheusfederation.loadbalancer.server.port=${MONITORING_PROMETHEUS_PORT}
- traefik.http.routers.prometheusfederation.rule=Host(`${MONITORING_DOMAIN}`) && PathPrefix(`/prometheusfederation`)
- traefik.http.routers.prometheusfederation.entrypoints=https
- traefik.http.routers.prometheusfederation.tls=true
- traefik.http.middlewares.prometheusfederation_stripprefixregex.stripprefixregex.regex=^/prometheusfederation
- traefik.http.routers.prometheusfederation.middlewares=ops_whitelist_ips@swarm, ops_auth@swarm, ops_gzip@swarm, prometheusfederation_stripprefixregex
- prometheus-job=prometheusfederation
- prometheus-port=${MONITORING_PROMETHEUS_PORT}
resources:
limits:
memory: 4096M
cpus: "2"
reservations:
memory: 64M
cpus: "0.2"
node-exporter:
image: prom/node-exporter:v1.8.2
volumes:
- /sys:/host/sys:ro
- /:/rootfs:ro
- /proc:/host/proc:ro
- /etc/hostname:/etc/nodename # doesn't work with windows
configs:
- source: node_exporter_entrypoint
target: /docker-entrypoint.sh
environment:
- NODE_ID={{ '{{.Node.ID}}' }}
command:
- "--path.procfs=/host/proc"
- "--path.rootfs=/rootfs"
- "--path.sysfs=/host/sys"
- "--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)"
- "--collector.textfile.directory=/home/"
- "--collector.meminfo_numa"
- "--no-collector.ipvs"
entrypoint:
- /bin/sh
- /docker-entrypoint.sh
networks:
- monitored
deploy:
labels:
- prometheus-job=node-exporter
- prometheus-port=9100
mode: global
resources:
limits:
memory: 128M
cpus: "0.5"
reservations:
memory: 64M
cpus: "0.1"
nvidia-exporter:
image: mindprince/nvidia_gpu_prometheus_exporter:0.1
networks:
- monitored
deploy:
labels:
- prometheus-job=nvidia-exporter
- prometheus-port=9445
placement:
constraints:
- node.labels.gpu==true
mode: global
resources:
limits:
memory: 64M
cpus: "0.5"
reservations:
memory: 32M
cpus: "0.1"
alertmanager:
image: prom/alertmanager:v0.27.0
volumes:
- alertmanager_data:/alertmanager
command:
- "--config.file=/etc/alertmanager/config.yml"
- "--storage.path=/alertmanager"
networks:
- monitored
configs:
- source: alertmanager_config
target: /etc/alertmanager/config.yml
deploy:
placement:
constraints:
- node.role==manager
resources:
limits:
memory: 32M
cpus: "0.5"
reservations:
memory: 16M
cpus: "0.1"
docker-events-exporter:
image: itisfoundation/docker-events-exporter:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
user: root # only user root can use the docker socket
networks:
- monitored
deploy:
labels:
- prometheus-job=docker-events-exporter
- prometheus-port=8000
mode: global
resources:
limits:
memory: 64M
cpus: "0.5"
reservations:
memory: 32M
cpus: "0.1"
grafana:
image: grafana/grafana-oss:11.2.4
volumes:
- grafana_data:/var/lib/grafana
env_file:
- ./grafana/config.monitoring
user: "104"
networks:
- monitored # needed to access postgres
- public
deploy:
#restart_policy:
# condition: on-failure
labels:
- traefik.enable=true
- traefik.docker.network=${PUBLIC_NETWORK}
# direct access through port
- traefik.http.services.grafana.loadbalancer.server.port=3000
- traefik.http.routers.grafana.rule=Host(`${MONITORING_DOMAIN}`) && PathPrefix(`/grafana`)
- traefik.http.routers.grafana.entrypoints=https
- traefik.http.routers.grafana.tls=true
- traefik.http.middlewares.grafana_replace_regex.replacepathregex.regex=^/grafana/?(.*)$$
- traefik.http.middlewares.grafana_replace_regex.replacepathregex.replacement=/$${1}
- traefik.http.routers.grafana.middlewares=ops_whitelist_ips@swarm, ops_gzip@swarm, grafana_replace_regex
resources:
limits:
memory: 256M
cpus: "1.0"
reservations:
memory: 128M
cpus: "0.1"
smokeping-prober-exporter:
image: quay.io/superq/smokeping-prober:v0.8.1
networks:
- monitored
volumes: []
cap_add:
- 'NET_ADMIN'
- 'NET_RAW'
entrypoint:
/bin/smokeping_prober --config.file=/smokeping_prober_config.yaml
configs:
- source: smokeping_prober_config
target: /smokeping_prober_config.yaml
deploy:
labels:
- prometheus-job=smokeping-prober-exporter
- prometheus-port=9374
mode: global
resources:
limits:
memory: 128M
cpus: "0.5"
reservations:
memory: 32M
cpus: "0.1"
dcgm-exporter:
cap_add:
- SYS_ADMIN
image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.7-3.5.0-ubuntu22.04
hostname: '{{'{{.Node.Hostname}}'}}'
networks:
- monitored
deploy:
mode: global
placement:
constraints:
- node.labels.gpu==true
resources:
limits:
memory: 512M
cpus: "0.5"
reservations:
memory: 256M
cpus: "0.1"
labels:
- prometheus-job=dcgm-exporter
- prometheus-port=9400
pgsql-query-exporter:
image: adonato/query-exporter:2.10.0
volumes: []
dns: 9.9.9.9
configs:
- source: pgsql_query_exporter_config
target: /config/config.yaml
networks:
- monitored
- public
extra_hosts: []
deploy:
labels:
- prometheus-job=pgsql-query-exporter
- prometheus-port=9560
placement:
constraints:
- node.labels.prometheus==true
resources:
limits:
memory: 128M
cpus: "0.5"
reservations:
memory: 64M
cpus: "0.1"
postgres-exporter:
image: bitnami/postgres-exporter:0.15.0
networks:
- monitored
environment:
- DATA_SOURCE_NAME=postgresql://{{POSTGRES_USER}}:{{POSTGRES_PASSWORD}}@{{POSTGRES_HOST}}:{{POSTGRES_PORT}}/{{POSTGRES_DB}}?sslmode=disable
deploy:
labels:
- prometheus-job=postgres-exporter
- prometheus-port=9187
placement:
constraints:
- node.labels.prometheus==true
resources:
limits:
memory: 128M
cpus: "0.5"
reservations:
memory: 32M
cpus: "0.1"
redis-exporter:
image: oliver006/redis_exporter:v1.62.0-alpine
networks:
- monitored
environment:
REDIS_ADDR: ${REDIS_ADDRESS}
{%- if REDIS_USER %}
REDIS_USER: ${REDIS_USER}
{%- endif %}
REDIS_PASSWORD: ${REDIS_PASSWORD}
REDIS_EXPORTER_CHECK_KEYS: db0=user_id*client_session_id*alive,db0=user_id*client_session_id*resources,db1=project_lock*,db3=*
deploy:
labels:
- prometheus-job=redis-exporter
- prometheus-port=9121
placement:
constraints:
- node.labels.prometheus==true
resources:
limits:
memory: 64M
cpus: "0.5"
reservations:
memory: 32M
cpus: "0.1"
tempo:
image: grafana/tempo:2.6.1
command: "-target=scalable-single-binary -config.file=/etc/tempo.yaml"
configs:
- source: tempo_config
target: /etc/tempo.yaml
networks:
- monitored
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${PUBLIC_NETWORK}
- traefik.http.services.tempo.loadbalancer.server.port=9095
- traefik.http.routers.tempo.rule=Host(`${MONITORING_DOMAIN}`) && PathPrefix(`/tempo`)
- traefik.http.routers.tempo.priority=10
- traefik.http.routers.tempo.entrypoints=https
- traefik.http.routers.tempo.tls=true
- traefik.http.middlewares.tempo_replace_regex.replacepathregex.regex=^/tempo/?(.*)$$
- traefik.http.middlewares.tempo_replace_regex.replacepathregex.replacement=/$${1}
- traefik.http.routers.tempo.middlewares=ops_whitelist_ips@swarm, ops_gzip@swarm, tempo_replace_regex
resources:
limits:
memory: 2000M
cpus: "2.0"