Skip to content

Commit 86fe2f8

Browse files
authored
Merge pull request #193 from Runnect/feature/monitoring-infra
모니터링 인프라 구축: ELK + Prometheus/Grafana + Slack 알림
2 parents bd9216a + b76ffc4 commit 86fe2f8

21 files changed

Lines changed: 423 additions & 5 deletions

File tree

‎.env.example‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 로컬 모니터링 스택 실행 전, 이 파일을 .env로 복사하고 실제 값을 채우세요.
2+
# .env는 .gitignore에 포함되어 있어 커밋되지 않습니다.
3+
4+
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX

‎.github/CODEOWNERS‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
*.java @funnysunny08 @RinRinPARK @YuSuhwa-ve

‎.github/workflows/dev-cd.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: make application.properties 파일 생성
3434
run: |
3535
## create application.yml
36-
mkdir ./src/main/resources
36+
mkdir -p ./src/main/resources
3737
cd ./src/main/resources
3838
3939
# application.yml 파일 생성

‎.github/workflows/dev-ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: make application.properties 파일 생성
3131
run: |
3232
## create application.yml
33-
mkdir ./src/main/resources
33+
mkdir -p ./src/main/resources
3434
cd ./src/main/resources
3535
3636
# application.yml 파일 생성

‎.github/workflows/prod-cd.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: make application.properties 파일 생성
3535
run: |
3636
## create application.yml
37-
mkdir ./src/main/resources
37+
mkdir -p ./src/main/resources
3838
cd ./src/main/resources
3939
4040
# application.yml 파일 생성

‎.github/workflows/prod-ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: make application.properties 파일 생성
2424
run: |
2525
## create application.yml
26-
mkdir ./src/main/resources
26+
mkdir -p ./src/main/resources
2727
cd ./src/main/resources
2828
2929
# application.yml 파일 생성

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ application.yaml
4242

4343
### DS_Store
4444
.DS_Store
45+
logs/
46+
test_write.tmp
47+
.env

‎Dockerfile‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# --- Build stage ---
2+
FROM gradle:8.2.1-jdk11 AS build
3+
WORKDIR /app
4+
5+
COPY build.gradle settings.gradle ./
6+
COPY gradle ./gradle
7+
COPY gradlew ./
8+
9+
COPY src ./src
10+
11+
# 로컬/모니터링 검증용 application.yml은 build context 루트에 두고 복사한다.
12+
# (CI/CD에서는 GitHub Secret으로 별도 생성 — 이 Dockerfile은 로컬 검증 전용)
13+
COPY application.yml ./application.yml
14+
15+
RUN ./gradlew bootJar -x test --no-daemon
16+
17+
# --- Run stage ---
18+
FROM eclipse-temurin:11-jre
19+
WORKDIR /app
20+
21+
COPY --from=build /app/build/libs/*.jar app.jar
22+
COPY --from=build /app/application.yml application.yml
23+
24+
EXPOSE 8080
25+
26+
ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-jar", "app.jar", "--spring.config.location=file:./application.yml"]

‎build.gradle‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ dependencies {
3131
// Health Check
3232
implementation 'org.springframework.boot:spring-boot-starter-actuator'
3333

34+
// Monitoring - Prometheus
35+
implementation 'io.micrometer:micrometer-registry-prometheus:1.9.14'
36+
3437
// JPA & Database
3538
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
3639
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.27'

‎docker-compose.yml‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
version: "3.8"
2+
3+
services:
4+
runnect-app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
container_name: runnect-app
9+
ports:
10+
- "8080:8080"
11+
depends_on:
12+
- postgres
13+
- redis
14+
volumes:
15+
- ./logs:/app/logs
16+
networks:
17+
- runnect-net
18+
19+
postgres:
20+
image: postgres:15
21+
container_name: runnect-postgres
22+
environment:
23+
POSTGRES_DB: runnect
24+
POSTGRES_USER: runnect
25+
POSTGRES_PASSWORD: runnect_local_password
26+
ports:
27+
- "5432:5432"
28+
volumes:
29+
- postgres_data:/var/lib/postgresql/data
30+
networks:
31+
- runnect-net
32+
33+
redis:
34+
image: redis:7
35+
container_name: runnect-redis
36+
ports:
37+
- "6379:6379"
38+
networks:
39+
- runnect-net
40+
41+
elasticsearch:
42+
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.4
43+
container_name: runnect-elasticsearch
44+
environment:
45+
- discovery.type=single-node
46+
- xpack.security.enabled=false
47+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
48+
ports:
49+
- "9200:9200"
50+
networks:
51+
- runnect-net
52+
53+
logstash:
54+
image: docker.elastic.co/logstash/logstash:8.13.4
55+
container_name: runnect-logstash
56+
depends_on:
57+
- elasticsearch
58+
volumes:
59+
- ./logstash.conf:/usr/share/logstash/pipeline/logstash.conf
60+
- ./logs:/usr/share/logstash/logs
61+
- logstash_data:/usr/share/logstash/data
62+
ports:
63+
- "5044:5044"
64+
networks:
65+
- runnect-net
66+
67+
kibana:
68+
image: docker.elastic.co/kibana/kibana:8.13.4
69+
container_name: runnect-kibana
70+
depends_on:
71+
- elasticsearch
72+
environment:
73+
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
74+
ports:
75+
- "5601:5601"
76+
networks:
77+
- runnect-net
78+
79+
prometheus:
80+
image: prom/prometheus:latest
81+
container_name: runnect-prometheus
82+
volumes:
83+
- ./prometheus.yml:/etc/prometheus/prometheus.yml
84+
ports:
85+
- "9090:9090"
86+
depends_on:
87+
- runnect-app
88+
networks:
89+
- runnect-net
90+
91+
grafana:
92+
image: grafana/grafana:latest
93+
container_name: runnect-grafana
94+
environment:
95+
- GF_SECURITY_ADMIN_USER=admin
96+
- GF_SECURITY_ADMIN_PASSWORD=admin
97+
- SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL}
98+
volumes:
99+
- ./grafana/provisioning:/etc/grafana/provisioning
100+
- grafana_data:/var/lib/grafana
101+
ports:
102+
- "3000:3000"
103+
depends_on:
104+
- prometheus
105+
networks:
106+
- runnect-net
107+
108+
networks:
109+
runnect-net:
110+
driver: bridge
111+
112+
volumes:
113+
postgres_data:
114+
grafana_data:
115+
logstash_data:

0 commit comments

Comments
 (0)