Spring Boot - Actuator

TopOfTheHead·2025년 10월 18일

Spring Boot

목록 보기
7/25

Spring Boot Actuator

Spring상태와 각종 지표 ( Health, Metrics 등 )을 확인하고 관리할 수 있도록 해주는 모듈
어플리케이션 Background에서 모니터링Metric들을 노출된 endpoint에서 수집하여 어떤 작업이 발생하는지 확인하는 등의 정보를 제공

/actuator 엔드포인트를 통해 CPU, 메모리 사용량, DB 커넥션 상태 등 다양한 정보를 노출

보통 ActuatorEndpoint를 노출시켜서 해당 EndpointMetricPrometheus에서 수집하여 Grafana로 시각화
/actuator/prometheus엔드포인트에서 Metric을 수집

implementation 'org.springframework.boot:spring-boot-starter-actuator'

build.gradle에 다음 의존성을 정의 후
http://localhost:8080/actuator 접속.

JSON Format으로 현재 Page의 URL로 연결되는 self link / health URL로 연결되는 health link가 반환.

ActuatorEndpoint를 노출 시 application.yml에서 정의.
기본 설정actuator 의존성을 추가 시 health endpoint만 노출되며 더 많은 endpoint를 좀 더 노출시키기 위해 다음 구문을 추가.

management:endpoints:web:exposure:include: "엔드포인트1,..." : 특정 endpoint 노출 시

management:endpoints:web:exposure:include: * : 모든 end point를 노출 할 경우.
Endpoint를 많이 노출하면 해당 정보를 많이 수집한다는 것을 의미하며 이는 CPU와 메모리를 많이 사용한다는 의미이므로 좋지 않다.

management:
  endpoints:
    web:
      exposure:
        include: "health,metrics,info,prometheus"
  endpoint:
    health:
      show-details: always  # 상세한 헬스 정보 표시

모니터링 시 다음처럼 설정하여 노출된 Endpoint로 표시되는 Metric들을 Prometheus에 의해 수집

end point 종류

  • prometheus endpoint
    Prometheus/actuator/prometheus엔드포인트에서 Metric을 수집
    spring-boot-starter-actuator 의존성에서 기본적으로 포함

  • beans endpoint :
    application에 포함된 모든 spring bean을 해당 endpoint를 이용하여 선언.

  • health endpoint :
    application의 정상작동 여부 등 의 상태 정보를 확인

  • metrics endpoint :
    application 관련 metrics 정보를 확인

  • mapping endpoint :
    application에서 정의된 모든 request mapping 관련 세부 사항

  • configprops endpoint :
    application.properties에서 설정 가능한 모든 항목들이 표시.

  • env endpoint :
    application 환경에 관한 세부 사항을 모두 표시.
profile
공부기록 블로그

0개의 댓글