Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,31 @@ services:
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
depends_on:
- kafka

prometheus:
image: prom/prometheus:latest
container_name: momogo-prometheus
ports:
- "9090:9090"
Comment thread
SungHuii marked this conversation as resolved.
Outdated
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
extra_hosts:
- "host.docker.internal:host-gateway"

grafana:
image: grafana/grafana:latest
container_name: momogo-grafana
ports:
- "3000:3000"
volumes:
- grafana-data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
Comment thread
SungHuii marked this conversation as resolved.
Outdated
depends_on:
- prometheus

volumes:
prometheus-data:
grafana-data:
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public SecurityFilterChain filterChain(
.requestMatchers("/", "/index.html").permitAll()
.requestMatchers("/ws/**").permitAll()
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**").permitAll()
.requestMatchers("/actuator/health", "/actuator/info").permitAll()
.requestMatchers("/actuator/health", "/actuator/info", "/actuator/prometheus").permitAll()
Comment thread
SungHuii marked this conversation as resolved.
Outdated
.requestMatchers("/actuator/**").hasRole("SUPER_ADMIN")
.requestMatchers("/api/super-admin/**").hasRole("SUPER_ADMIN")

Expand Down
17 changes: 17 additions & 0 deletions momogo-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,20 @@ app:

server:
port: 8080

# monitoring
management:
endpoints:
web:
exposure:
include: health, info, prometheus, metrics
prometheus:
metrics:
export:
enabled: true
metrics:
tags:
application: ${spring.application.name:momogo-api}
distribution:
percentiles-histogram:
http.server.requests: true
1 change: 1 addition & 0 deletions momogo-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies {
api 'org.springframework.boot:spring-boot-starter-data-jpa'
api 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
api 'io.micrometer:micrometer-registry-prometheus'
runtimeOnly 'org.postgresql:postgresql'

// QueryDSL (Spring Boot 3.x / Jakarta)
Expand Down
25 changes: 25 additions & 0 deletions prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
global:
scrape_interval: 5s # 5초마다 메트릭 수집 (부하 테스트 모니터링을 위해 조금 짧게 설정)
evaluation_interval: 5s

scrape_configs:
- job_name: 'momogo-local-api'
metrics_path: '/actuator/prometheus'
scheme: 'http'
scrape_interval: 5s
static_configs:
# 로컬에서 호스트 PC의 Spring Boot 서버(8080)에 접근하기 위해 hoost.docker.internal 사용
- targets: ['host.docker.internal:8080']
labels:
env: 'local'
application: 'momogo-api'

- job_name: 'momogo-prod-api'
metrics_path: '/actuator/prometheus'
scheme: 'http'
scrape_interval: 5s
static_configs:
- targets: ['momogo.kro.kr']
Comment thread
coderabbitai[bot] marked this conversation as resolved.
labels:
env: 'production'
application: 'momogo-api'