[MSA] Actuator 추가

jineey·2024년 11월 21일

MSA

목록 보기
22/36

Actuator

📌 Actuator 이란?

  • 스프링 부트에서는 spring-boot-actuator 모듈을 통해 이러한 모니터링 기능을 지원할 뿐만 아니라 서비스를 일부 조작할 수 있게 지원
  • 엔드포인트를 활성화하고 노출까지 둘다 적용해야 사용할 수 있다.

📌 소스코드

User-service

  • pom.xml 수정
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
  • application.yaml 수정
management:
  endpoints:
    web:
      exposure:
        include: refresh, health, beans
  1. Spring Boot는 애플리케이션의 상태와 관리 작업을 위한 여러 엔드포인트를 제공하는데, 그 엔드포인트들의 노출을 설정하는 방법을 정의한 부분
  2. Spring Boot 애플리케이션이 제공하는 /actuator/refresh, /actuator/health, /actuator/beans 엔드포인트는 외부에서 접근 가능하도록 설정
  3. 애플리케이션 상태 점검, 설정 변경, 빈(Bean) 상태 확인 등을 위해 사용

📌 실행결과

  • /actuator/health
  • /actuator/beans
  • /actuator/refresh
    1. 기존

    2. token.secret 변경

    3. /actuator/refresh 실행

    4. 변경사항 확인

    재부팅 하지 않고 설정사항을 적용 가능
profile
새싹 개발자

0개의 댓글