diff --git a/prothsync/build.gradle b/prothsync/build.gradle index f006036..517c331 100644 --- a/prothsync/build.gradle +++ b/prothsync/build.gradle @@ -48,6 +48,9 @@ dependencies { runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6' implementation 'org.springframework.boot:spring-boot-starter-webflux' + + implementation 'org.springframework.boot:spring-boot-starter-actuator' + runtimeOnly 'io.micrometer:micrometer-registry-prometheus' } tasks.named('test') { diff --git a/prothsync/monitoring/prometheus/prometheus.yml b/prothsync/monitoring/prometheus/prometheus.yml new file mode 100644 index 0000000..b778f9e --- /dev/null +++ b/prothsync/monitoring/prometheus/prometheus.yml @@ -0,0 +1,11 @@ +global: + scrape_interval: 15s # 15초마다 메트릭 수집 + evaluation_interval: 15s # 15초마다 알림 규칙 평가 + +scrape_configs: + - job_name: 'prothsync' + metrics_path: '/actuator/prometheus' + static_configs: + - targets: ['host.docker.internal:8080'] + labels: + application: 'prothsync' \ No newline at end of file diff --git a/prothsync/src/main/java/com/prothsync/prothsync/config/SecurityConfig.java b/prothsync/src/main/java/com/prothsync/prothsync/config/SecurityConfig.java index 2718cc5..bdc2cf5 100644 --- a/prothsync/src/main/java/com/prothsync/prothsync/config/SecurityConfig.java +++ b/prothsync/src/main/java/com/prothsync/prothsync/config/SecurityConfig.java @@ -43,6 +43,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .requestMatchers("/api/auth/signup", "/api/auth/login", "/api/auth/refresh").permitAll() // Swagger .requestMatchers("/swagger-ui/**", "/v3/api-docs/**").permitAll() + .requestMatchers("/actuator/health", "/actuator/prometheus").permitAll() .requestMatchers("/", "/index.html", "/css/**", "/js/**", "/images/**", "/favicon.ico").permitAll() // Posts - 공개 조회 .requestMatchers(HttpMethod.GET, "/api/posts").permitAll() diff --git a/prothsync/src/main/resources/application.yaml b/prothsync/src/main/resources/application.yaml index 1e7a1a4..f785d8a 100644 --- a/prothsync/src/main/resources/application.yaml +++ b/prothsync/src/main/resources/application.yaml @@ -31,4 +31,16 @@ jwt: kakao: rest-api-key: ${KAKAO_REST_API_KEY} geocoding: - base-url: https://dapi.kakao.com \ No newline at end of file + base-url: https://dapi.kakao.com + +management: + endpoints: + web: + exposure: + include: health, info, prometheus, metrics + endpoint: + health: + show-details: when-authorized + metrics: + tags: + application: prothsync \ No newline at end of file