-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdocker-compose-observability.yml
More file actions
380 lines (372 loc) · 15.1 KB
/
Copy pathdocker-compose-observability.yml
File metadata and controls
380 lines (372 loc) · 15.1 KB
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
name: observability
x-healthcheck-defaults: &healthcheck-defaults
interval: 60s
retries: 5
start_period: 30s
timeout: 10s
x-limit-grafana: &limit-grafana
deploy:
resources:
limits:
memory: ${GRAFANA_MEMORY}
cpus: "${GRAFANA_CPUS}"
x-limit-telemetry: &limit-telemetry
deploy:
resources:
limits:
memory: ${TELEMETRY_MEMORY}
cpus: "${TELEMETRY_CPUS}"
x-limit-log-rotator: &limit-log-rotator
deploy:
resources:
limits:
memory: ${LOG_ROTATOR_MEMORY}
cpus: "${LOG_ROTATOR_CPUS}"
secrets:
# Owned by sabnzbd (docker-compose-nzb.yml) and qbittorrent
# (docker-compose-torrent.yml) respectively; declared here identically so
# this file resolves standalone (it is: `make start_observability`).
# See docs/COMPOSE_CONVENTIONS.md.
sabnzbd_api_key:
file: ./configs/sabnzbd/secrets/api_key.txt
x-podman.relabel: z
qbittorrent_username:
file: ./configs/qbittorrent/secrets/username.txt
x-podman.relabel: z
qbittorrent_password:
file: ./configs/qbittorrent/secrets/password.txt
x-podman.relabel: z
# Owned here since grafana is the service in this file; homepage
# (docker-compose-proxy.yml) declares an identical copy.
grafana_homepage_auth:
file: ./configs/grafana/secrets/homepage_auth.txt
x-podman.relabel: z
# Consumed only by grafana itself (single consumer, no duplicate needed
# elsewhere), referenced directly from grafana.ini via Grafana's own
# $__file{} config provider, not an env var.
grafana_smtp_user:
file: ./configs/grafana/secrets/smtp_user.txt
x-podman.relabel: z
grafana_smtp_password:
file: ./configs/grafana/secrets/smtp_password.txt
x-podman.relabel: z
services:
cadvisor:
<<: *limit-telemetry
image: gcr.io/cadvisor/cadvisor:${CADVISOR_VERSION}
container_name: ${CONTAINER_PREFIX}cadvisor
profiles: ["${CADVISOR_PROFILE}"]
networks: ["observability"]
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
privileged: true
devices:
- /dev/kmsg
command:
- '--url_base_prefix=/admin/cadvisor'
- '--port=${CADVISOR_HTTP_PORT}'
- '--docker_only=true'
- '--podman=unix:///var/run/podman/podman.sock'
env_file: ["${CONFIG_FOLDER}/cadvisor/.env"]
environment:
- CADVISOR_HEALTHCHECK_URL=http://localhost:${CADVISOR_HTTP_PORT}/admin/cadvisor/healthz
volumes:
- /:/rootfs:ro
- /run/user/${UID}/podman/podman.sock:/var/run/docker.sock:ro
- /run/user/${UID}/podman/podman.sock:/var/run/podman/podman.sock:ro
- /sys:/sys:ro
- /sys/fs/cgroup:/cgroup:ro
healthcheck:
<<: *healthcheck-defaults
test: wget -q -O /dev/null http://127.0.0.1:${CADVISOR_HTTP_PORT}/admin/cadvisor/healthz || exit 1
podman_exporter:
<<: *limit-telemetry
image: quay.io/navidys/prometheus-podman-exporter:${PODMAN_EXPORTER_VERSION}
container_name: ${CONTAINER_PREFIX}podman_exporter
profiles: ["${PODMAN_EXPORTER_PROFILE}"]
networks: ["observability"]
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
userns_mode: "keep-id:uid=65534,gid=65534"
security_opt:
- label=disable
command: ["--collector.enable-all", "--collector.enhance-metrics"]
env_file: ["${CONFIG_FOLDER}/podman_exporter/.env"]
environment:
- CONTAINER_HOST=unix:///var/run/podman/podman.sock
volumes:
- /run/user/${UID}/podman/podman.sock:/var/run/podman/podman.sock:ro
healthcheck:
<<: *healthcheck-defaults
test: wget -q -O /dev/null http://127.0.0.1:9882/metrics || exit 1
podman_limits_exporter:
<<: *limit-telemetry
image: docker.io/library/python:${PODMAN_LIMITS_EXPORTER_VERSION}
container_name: ${CONTAINER_PREFIX}podman_limits_exporter
profiles: ["${PODMAN_LIMITS_EXPORTER_PROFILE}"]
networks: ["observability"]
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
userns_mode: "keep-id:uid=0,gid=0"
security_opt:
- label=disable
command: ["python3", "/exporter.py"]
env_file: ["${CONFIG_FOLDER}/podman_limits_exporter/.env"]
volumes:
- /run/user/${UID}/podman/podman.sock:/var/run/podman/podman.sock:ro
- ${CONFIG_FOLDER}/../scripts/podman-limits-exporter.py:/exporter.py:ro
healthcheck:
<<: *healthcheck-defaults
test: wget -q -O /dev/null http://127.0.0.1:9889/metrics || exit 1
node_exporter:
<<: *limit-telemetry
image: docker.io/prom/node-exporter:${NODE_EXPORTER_VERSION}
container_name: ${CONTAINER_PREFIX}node_exporter
profiles: ["${NODE_EXPORTER_PROFILE}"]
networks: ["observability"]
# ports:
# - ${NODE_EXPORTER_HTTP_PORT}:9100 # node-exporter-http
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
command:
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
- '--collector.hwmon.chip-exclude=platform_asus_nb_wmi'
- '--web.telemetry-path=/admin/node_exporter/metrics'
env_file: ["${CONFIG_FOLDER}/node_exporter/.env"]
volumes:
- /sys:/host/sys:ro
- /:/rootfs:ro
healthcheck:
<<: *healthcheck-defaults
test: wget -q -O /dev/null http://127.0.0.1:${NODE_EXPORTER_HTTP_PORT}/admin/node_exporter/metrics || exit 1
alloy:
<<: *limit-telemetry
deploy:
resources:
limits:
memory: ${ALLOY_MEMORY}
cpus: "${TELEMETRY_CPUS}"
image: docker.io/grafana/alloy:${ALLOY_VERSION}
container_name: ${CONTAINER_PREFIX}alloy
profiles: ["${ALLOY_PROFILE}"]
networks: ["observability"]
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
stop_grace_period: 30s
user: "${ALLOY_UID}:${ALLOY_GID}"
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
cap_add: [DAC_READ_SEARCH]
command: ["run", "--server.http.listen-addr=0.0.0.0:${ALLOY_HTTP_PORT}", "--storage.path=/alloy-data", "/etc/alloy/config.alloy"]
env_file: ["${CONFIG_FOLDER}/alloy/.env"]
volumes:
- ${LOGS_FOLDER}/nginx:/nginxlogs:ro
- ${CONFIG_FOLDER}/sabnzbd/config/logs:/sabnzbdlogs:ro
- ${CONFIG_FOLDER}/qbittorrent/config/qBittorrent/logs:/qbittorrentlogs:ro
- ${CONFIG_FOLDER}/jdownloader2/config/log:/jdownloader2logs:ro
- ${CONFIG_FOLDER}/alloy/config/config.alloy:/etc/alloy/config.alloy:ro,z
- ${STORAGE_FOLDER}/alloy/data:/alloy-data:z
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "/usr/bin/alloy", "--version"]
log_rotator:
<<: *limit-log-rotator
image: docker.io/alpine:${LOG_ROTATOR_VERSION}
container_name: ${CONTAINER_PREFIX}log_rotator
profiles: ["${LOG_ROTATOR_PROFILE}"]
restart: unless-stopped
user: "${LOG_ROTATOR_UID}:${LOG_ROTATOR_GID}"
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
command:
- /bin/sh
- -c
- |
trap 'kill "$${sleep_pid:-0}" 2>/dev/null; exit 0' TERM INT
while true; do
/scripts/rotate-nginx-logs.sh
sleep "$${LOG_ROTATION_INTERVAL_SECONDS:-86400}" &
sleep_pid=$$!
wait "$$sleep_pid"
done
env_file: [".env"]
environment:
LOGS_FOLDER: /logs
volumes:
- ${LOGS_FOLDER}/nginx:/logs/nginx:z
- ./scripts/rotate-nginx-logs.sh:/scripts/rotate-nginx-logs.sh:ro,z
prometheus:
<<: *limit-telemetry
image: docker.io/prom/prometheus:${PROMETHEUS_VERSION}
container_name: ${CONTAINER_PREFIX}prometheus
profiles: ["${PROMETHEUS_PROFILE}"]
networks: ["observability"]
# ports:
# - ${PROMETHEUS_HTTP_PORT}:9090 # prometheus-http
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
stop_grace_period: 30s
user: "${PROMETHEUS_UID}:${PROMETHEUS_GID}"
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION_TIME}'
- '--storage.tsdb.retention.size=${PROMETHEUS_RETENTION_SIZE}'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- '--web.external-url=/admin/prometheus/'
- '--web.route-prefix=/admin/prometheus/'
env_file: ["${CONFIG_FOLDER}/prometheus/.env"]
volumes:
- /etc/localtime:/etc/localtime:ro
- ${CONFIG_FOLDER}/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro,z
- ${STORAGE_FOLDER}/prometheus/data:/prometheus:z
healthcheck:
<<: *healthcheck-defaults
test: wget -q -O /dev/null http://127.0.0.1:${PROMETHEUS_HTTP_PORT}/admin/prometheus/-/healthy || exit 1
loki:
<<: *limit-telemetry
image: docker.io/grafana/loki:${LOKI_VERSION}
container_name: ${CONTAINER_PREFIX}loki
profiles: ["${LOKI_PROFILE}"]
networks: ["observability"]
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
user: "${LOKI_UID}:${LOKI_GID}"
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
command: ["-config.file=/etc/loki/loki.yml", "-config.expand-env=true"]
env_file: [".env"]
volumes:
- /etc/localtime:/etc/localtime:ro
- ${CONFIG_FOLDER}/loki/config/loki.yml:/etc/loki/loki.yml:ro,z
- ${STORAGE_FOLDER}/loki/data:/loki:z
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "/usr/bin/loki", "-version"]
grafana:
<<: *limit-grafana
image: docker.io/grafana/grafana-oss:${GRAFANA_VERSION}
container_name: ${CONTAINER_PREFIX}grafana
profiles: ["${GRAFANA_PROFILE}"]
networks: ["observability", "apps"]
# ports:
# - ${GRAFANA_HTTP_PORT}:3000 # grafana-http (disabled: access via nginx /admin/grafana/)
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
user: "${GRAFANA_UID}:${GRAFANA_GID}"
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
env_file: ["${CONFIG_FOLDER}/grafana/.env", "${CONFIG_FOLDER}/grafana/.env.secrets"]
# environment:
# - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
# - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
# - GF_USERS_ALLOW_SIGN_UP=false
# - GF_SERVER_ROOT_URL=https://172.16.15.30/admin/grafana
secrets: [grafana_smtp_user, grafana_smtp_password]
volumes:
- /etc/localtime:/etc/localtime:ro
- ${CERTIFICATES_FOLDER}:/certs:ro,z
- ${CONFIG_FOLDER}/grafana/config/grafana.ini:/etc/grafana/grafana.ini:z
- ${CONFIG_FOLDER}/grafana/config/provisioning/dashboards:/etc/grafana/provisioning/dashboards:z
- ${CONFIG_FOLDER}/grafana/config/provisioning/datasources:/etc/grafana/provisioning/datasources:z
- ${CONFIG_FOLDER}/grafana/config/provisioning/alerting:/etc/grafana/provisioning/alerting:z
- ${STORAGE_FOLDER}/grafana/data:/var/lib/grafana:z
healthcheck:
<<: *healthcheck-defaults
test: curl --fail http://127.0.0.1:${GRAFANA_HTTP_PORT}/api/health || exit 1
nginx_exporter:
<<: *limit-telemetry
image: docker.io/nginx/nginx-prometheus-exporter:${NGINX_EXPORTER_VERSION}
container_name: ${CONTAINER_PREFIX}nginx_exporter
profiles: ["${NGINX_EXPORTER_PROFILE}"]
networks: ["observability"]
sysctls: ["net.ipv6.conf.all.disable_ipv6=1", net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1]
restart: unless-stopped
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
command: ["--nginx.scrape-uri=http://nginx/stub_status"]
env_file: ["${CONFIG_FOLDER}/nginx_exporter/.env"]
healthcheck:
<<: *healthcheck-defaults
test: ["CMD", "/usr/bin/nginx-prometheus-exporter", "--version"]
qbittorrent_exporter:
<<: *limit-telemetry
image: ghcr.io/esanchezm/prometheus-qbittorrent-exporter:${QBITTORRENT_EXPORTER_VERSION}
container_name: ${CONTAINER_PREFIX}qbittorrent_exporter
profiles: ["${QBITTORRENT_EXPORTER_PROFILE}"]
networks: ["observability", "services"]
restart: unless-stopped
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
entrypoint: ["python"]
command: ["/app/exporter_extended.py"]
env_file: ["${CONFIG_FOLDER}/qbittorrent_exporter/.env", "${CONFIG_FOLDER}/qbittorrent_exporter/.env.secrets"]
environment:
- QBITTORRENT_PORT=${QBITTORRENT_HTTPS_PORT}
- QBITTORRENT_HOST=${GLUETUN_SERVICES_IP}
# exporter_extended.py already implements the FILE__<VAR> convention
# itself (reads the path, strips the contents), so no shim is needed
# here the way sabnzbd_exporter needed one.
- FILE__QBITTORRENT_USER=/run/secrets/qbittorrent_username
- FILE__QBITTORRENT_PASS=/run/secrets/qbittorrent_password
secrets: [qbittorrent_username, qbittorrent_password]
volumes:
- ${CONFIG_FOLDER}/qbittorrent_exporter/exporter_extended.py:/app/exporter_extended.py:ro,z
healthcheck:
<<: *healthcheck-defaults
test: wget -q -O /dev/null http://127.0.0.1:17871/metrics || exit 1
sabnzbd_exporter:
<<: *limit-telemetry
image: docker.io/msroest/sabnzbd_exporter:${SABNZBD_EXPORTER_VERSION}
container_name: ${CONTAINER_PREFIX}sabnzbd_exporter
profiles: ["${SABNZBD_EXPORTER_PROFILE}"]
networks: ["observability", "services"]
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
- net.ipv6.conf.default.disable_ipv6=1
- net.ipv6.conf.lo.disable_ipv6=1
restart: unless-stopped
security_opt:
- no-new-privileges:true
cap_drop: [ALL]
# The image reads its API key only from SABNZBD_APIKEYS and has no file
# based equivalent, so a shell shim exports the mounted secret before
# handing off to the image's own entrypoint (python /sabnzbd_exporter.py).
# $$ escapes the substitution so compose leaves it for the inner shell.
entrypoint: ["/bin/sh", "-c"]
command:
- >-
export SABNZBD_APIKEYS="$$(cat /run/secrets/sabnzbd_api_key)";
exec python /sabnzbd_exporter.py
env_file: ["${CONFIG_FOLDER}/sabnzbd_exporter/.env"]
environment:
- SABNZBD_BASEURLS=http://${GLUETUN_SERVICES_IP}:${SABNZBD_HTTP_PORT}/sabnzbd
secrets: [sabnzbd_api_key]
healthcheck:
<<: *healthcheck-defaults
test: wget -q -O /dev/null http://127.0.0.1:9387/metrics || exit 1
networks:
observability:
external: true
name: ${COMPOSE_PROJECT_NAME:-docker-torrent-box-with-vpn}_observability
services:
external: true
name: ${COMPOSE_PROJECT_NAME:-docker-torrent-box-with-vpn}_services
apps:
external: true
name: ${COMPOSE_PROJECT_NAME:-docker-torrent-box-with-vpn}_apps