서버가 올라가면, 살아있는지 아닌지 확인하는것이 필요하다. AWS 에 올린 후 로드벨런서를 달아놓게 된다면, 해당 설정에서 health check를 위한 경로를 입력하는 것이 있다.
Gradle에 다음을 추가한다.
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
}
application.yaml 에서 설정
management:
endpoints:
web:
exposure:
include: health, info, metrics, env
endpoint:
health:
show-details: always
사실, health 말고 다른 항목들도 많이 있다.
주요 엔드포인트는 다음과 같다.
엔드포인트설명
| /actuator/health | 애플리케이션 상태 확인 (DB, Disk, Network 등) |
| /actuator/info | 시스템 정보 표시 |
| /actuator/metrics | JVM, CPU, 메모리, 요청 수 등 메트릭 |
| /actuator/env | 환경변수 및 설정 확인 |
| /actuator/beans | 등록된 빈 목록 |
| /actuator/mappings | URL 매핑 정보 |
| /actuator/threaddump | 스레드 상태 정보 |
| /actuator/loggers | 런타임 중 로그 레벨 제어 가능 |
만일, Spring Security를 사용할 경우, 보안을 풀어주어야 한다.
@Configuration
public class ActuatorSecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/actuator/health", "/actuator/info").permitAll()
.requestMatchers("/actuator/**").hasRole("ADMIN")
.anyRequest().authenticated()
)
.httpBasic();
return http.build();
}
}'Backend > SpringBoot' 카테고리의 다른 글
| Flyway 사용하기 (0) | 2025.12.04 |
|---|---|
| Spring batch + 스케줄링 (0) | 2025.11.27 |
| 각종 설정 오버라이드 (WebMvcConfigurer) (0) | 2025.11.07 |
| Admin 페이지 설정하기 (0) | 2025.11.05 |
| @Valid, @Validated (0) | 2025.11.03 |