Skip to content

Commit 0d1df7d

Browse files
committed
Add Logging System
1 parent ad2a2d9 commit 0d1df7d

File tree

17 files changed

+953
-3
lines changed

17 files changed

+953
-3
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@ CHAT_USERNAME=mongodb_chat
5454
CHAT_ROOT_PASSWORD=dinhanst2832004
5555
CHAT_DATABASE=chat_db
5656
CHAT_PASSWORD=dinhanst2832004
57+
58+
GRAFANA_ADMIN_PASSWORD=dinhanst2832004
59+
5760
#GeminiKey
5861
OPENAI_API_KEY=AIzaSyB70AASubd5jiecmWY5NFnfPaGwe0nauUk

docker-compose.prod-infra.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,95 @@ services:
391391
retries: 5
392392
networks: [ backend ]
393393

394+
# ---------- Monitoring: Metrics (Prometheus/Grafana) ----------
395+
prometheus:
396+
image: bitnami/prometheus:latest
397+
container_name: prometheus
398+
restart: unless-stopped
399+
ports: [ "5555:9090" ]
400+
volumes:
401+
- prometheus_data:/opt/bitnami/prometheus/data
402+
- ./monitoring/prometheus.yml:/opt/bitnami/prometheus/conf/prometheus.yml:ro
403+
networks: [ backend ]
404+
405+
grafana:
406+
image: bitnami/grafana:latest
407+
container_name: grafana
408+
restart: unless-stopped
409+
ports: [ "5556:3000" ]
410+
environment:
411+
- GF_SECURITY_ADMIN_USER=admin
412+
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
413+
volumes:
414+
- grafana_data:/opt/bitnami/grafana/data
415+
# Tự động thêm data source Prometheus & Loki
416+
- ./monitoring/grafana/provisioning:/opt/bitnami/grafana/conf/provisioning
417+
depends_on:
418+
- prometheus
419+
- loki
420+
networks: [ backend ]
421+
422+
# Exporter lấy metrics host & container
423+
node-exporter:
424+
image: bitnami/node-exporter:latest
425+
container_name: node-exporter
426+
restart: unless-stopped
427+
command:
428+
- --path.rootfs=/host
429+
- --path.sysfs=/host/sys
430+
- --path.procfs=/host/proc
431+
- --collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)
432+
volumes:
433+
- /:/host:ro
434+
- /proc:/host/proc:ro
435+
- /sys:/host/sys:ro
436+
ports: [ "5557:9100" ]
437+
networks: [ backend ]
438+
439+
cadvisor:
440+
image: bitnami/cadvisor:latest
441+
container_name: cadvisor
442+
restart: unless-stopped
443+
ports: [ "5558:8080" ]
444+
volumes:
445+
- /:/rootfs:ro
446+
- /var/run:/var/run:ro
447+
- /sys:/sys:ro
448+
- /var/lib/docker/:/var/lib/docker:ro
449+
networks: [ backend ]
450+
451+
# ---------- Monitoring: Logs (Loki/Promtail) ----------
452+
loki:
453+
image: grafana/loki:3.4.1
454+
container_name: loki
455+
restart: unless-stopped
456+
command: -config.file=/etc/loki/config.yml
457+
ports: [ "5559:3100" ]
458+
volumes:
459+
- ./monitoring/loki-config.yml:/etc/loki/config.yml:ro
460+
- loki_data:/loki
461+
networks: [ backend ]
462+
463+
promtail:
464+
image: grafana/promtail:3.4.1
465+
container_name: promtail
466+
restart: unless-stopped
467+
command: -config.file=/etc/promtail/config.yml
468+
volumes:
469+
- ./monitoring/promtail-config.yml:/etc/promtail/config.yml:ro
470+
- /var/log:/var/log:ro
471+
- /var/lib/docker/containers:/var/lib/docker/containers:ro
472+
- /var/run/docker.sock:/var/run/docker.sock:ro
473+
networks: [ backend ]
474+
394475
networks:
395476
backend:
396477
name: codecampus_backend
397478

398479
volumes:
480+
prometheus_data:
481+
grafana_data:
482+
loki_data:
399483
organization_pg_data:
400484
payment_pg_data:
401485
identity_pg_data:

docker-compose.prod-services.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ services:
181181
networks: [ backend ]
182182

183183
file-service:
184-
build:
185-
context: .
186-
dockerfile: ./docker/file-service.Dockerfile
187184
image: ${DOCKERHUB_USER}/codecampus-file-service:${IMAGE_TAG:-latest}
188185
environment:
189186
- ASPNETCORE_ENVIRONMENT=Staging
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ---
2+
# # config file version
3+
# apiVersion: 2
4+
5+
# # <list> list of roles to insert/update/delete
6+
# roles:
7+
# # <string, required> name of the role you want to create or update. Required.
8+
# - name: 'custom:users:writer'
9+
# # <string> uid of the role. Has to be unique for all orgs.
10+
# uid: customuserswriter1
11+
# # <string> description of the role, informative purpose only.
12+
# description: 'Create, read, write users'
13+
# # <int> version of the role, Grafana will update the role when increased.
14+
# version: 2
15+
# # <int> org id. Defaults to Grafana's default if not specified.
16+
# orgId: 1
17+
# # <list> list of the permissions granted by this role.
18+
# permissions:
19+
# # <string, required> action allowed.
20+
# - action: 'users:read'
21+
# #<string> scope it applies to.
22+
# scope: 'global.users:*'
23+
# - action: 'users:write'
24+
# scope: 'global.users:*'
25+
# - action: 'users:create'
26+
# - name: 'custom:global:users:reader'
27+
# # <bool> overwrite org id and creates a global role.
28+
# global: true
29+
# # <string> state of the role. Defaults to 'present'. If 'absent', role will be deleted.
30+
# state: 'absent'
31+
# # <bool> force deletion revoking all grants of the role.
32+
# force: true
33+
# - uid: 'basic_editor'
34+
# version: 2
35+
# global: true
36+
# # <list> list of roles to copy permissions from.
37+
# from:
38+
# - uid: 'basic_editor'
39+
# global: true
40+
# - name: 'fixed:users:writer'
41+
# global: true
42+
# # <list> list of the permissions to add/remove on top of the copied ones.
43+
# permissions:
44+
# - action: 'users:read'
45+
# scope: 'global.users:*'
46+
# - action: 'users:write'
47+
# scope: 'global.users:*'
48+
# # <string> state of the permission. Defaults to 'present'. If 'absent', the permission will be removed.
49+
# state: absent
50+
51+
# # <list> list role assignments to teams to create or remove.
52+
# teams:
53+
# # <string, required> name of the team you want to assign roles to. Required.
54+
# - name: 'Users writers'
55+
# # <int> org id. Will default to Grafana's default if not specified.
56+
# orgId: 1
57+
# # <list> list of roles to assign to the team
58+
# roles:
59+
# # <string> uid of the role you want to assign to the team.
60+
# - uid: 'customuserswriter1'
61+
# # <int> org id. Will default to Grafana's default if not specified.
62+
# orgId: 1
63+
# # <string> name of the role you want to assign to the team.
64+
# - name: 'fixed:users:writer'
65+
# # <bool> overwrite org id to specify the role is global.
66+
# global: true
67+
# # <string> state of the assignment. Defaults to 'present'. If 'absent', the assignment will be revoked.
68+
# state: absent

0 commit comments

Comments
 (0)