3.5 KiB
3.5 KiB
좋아, 이어서 2부. 주요 엔드포인트 상세 분석을 작성해볼게. 실무에서 자주 쓰는 엔드포인트 중심으로 간결하게 구성하고, 예시도 함께 제공할게.
2부. 주요 엔드포인트 상세 분석
6장. /actuator/health — 헬스 체크
개요
애플리케이션의 현재 상태(UP, DOWN 등)를 알려주는 엔드포인트. 모니터링 시스템, 로드 밸런서의 상태 판단 기준으로 자주 사용됨.
기본 사용
curl http://localhost:8080/actuator/health
{
"status": "UP"
}
커스터마이징
management:
endpoint:
health:
show-details: always
{
"status": "UP",
"components": {
"diskSpace": {
"status": "UP",
"details": {
"total": 500000000000,
"free": 480000000000,
"threshold": 10485760
}
}
}
}
사용자 정의 헬스 인디케이터
@Component
public class MyHealthIndicator implements HealthIndicator {
@Override
public Health health() {
return Health.up().withDetail("custom", "OK").build();
}
}
7장. /actuator/info — 정보 제공
설정
info:
app:
name: actuator-demo
version: 1.0.0
curl http://localhost:8080/actuator/info
{
"app": {
"name": "actuator-demo",
"version": "1.0.0"
}
}
Git 정보 포함하기
build.gradle
plugins {
id "com.gorylenko.gradle-git-properties" version "2.4.0"
}
management:
info:
git:
mode: full
8장. /actuator/metrics — 메트릭 수집
개요
CPU, 메모리, 요청 횟수 등 주요 리소스 사용량 정보를 제공함.
curl http://localhost:8080/actuator/metrics
{
"names": [
"jvm.memory.used",
"jvm.gc.memory.promoted",
"http.server.requests",
...
]
}
특정 메트릭 조회
curl http://localhost:8080/actuator/metrics/http.server.requests
9장. /actuator/loggers — 로깅 레벨 제어
현재 로깅 레벨 조회
curl http://localhost:8080/actuator/loggers/com.example
런타임 레벨 변경
curl -X POST http://localhost:8080/actuator/loggers/com.example \
-H 'Content-Type: application/json' \
-d '{"configuredLevel": "DEBUG"}'
10장. /actuator/httptrace — HTTP 요청 추적
Spring Boot 2.6 이후 기본 미포함. 의존성 추가 필요.
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-actuator-autoconfigure'
management:
endpoint:
httptrace:
enabled: true
endpoints:
web:
exposure:
include: httptrace
11장. 기타 엔드포인트 요약
| 엔드포인트 | 설명 |
|---|---|
/actuator/beans |
등록된 스프링 빈 목록 |
/actuator/env |
환경 변수 및 프로퍼티 확인 |
/actuator/mappings |
URL-컨트롤러 매핑 확인 |
/actuator/threaddump |
스레드 덤프 출력 |
/actuator/configprops |
@ConfigurationProperties 설정 확인 |
/actuator/scheduledtasks |
스케줄링된 작업 정보 확인 |
다음은 3부 보안과 커스터마이징으로 이어지면 좋아. 계속 이어서 써줄까?