본문 바로가기

백엔드/자바

스프링 부트 엑츄에이터

반응형

스프링 부트 스타터 엑츄에이터를 사용하면 애플리케이션 관리와 모니터링에 관한 정보를 확인할 수 있습니다.

목차

디펜던시

구현에 필요한 디펜던시는 아래와 같습니다.

▶ Actuator

애플리케이션 관리와 정보를 담은 엔트포인트를 제공

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

엔드포인트

엔드포인트 리스트

대표적인 엔드포인트 리스트는 아래와 같습니다.

▶ actuator/health

애플리케이션 상태 표시

▶ actuator/info

애플리케이션 추가 정보 제공, 정보는 직접 추가해야 함


아래 속성명을 사용하여 application.properties 파일에 필요한 정보를 추가. 추가된 정보는 JSON 객체 형태로 생성되며 마침표 뒤에 오는 객체는 마침표 앞에 오는 객체의 자식이 됨

info.<name>.<name>=<value>


▶ actuator/beans

애플리케이션 콘텍스트에 등록된 빈 목록 보여줌

▶ actuator/mappings

등록된 모든 @RequestMapping 경로를 보여줌

엔드포인트 추가하기

▶ 특정 엔드포인트

기본적으로 사용가능한 엔드포인트는 /health 밖에 없으며 나머지 엔드포인트는 application.properties 에서 아래와 같이 필요한 엔드포인트를 추가

management.endpoints.web.exposure.include=<endpoint1>,<endpoint2>

▶ 모든 엔드포인트

값으로 *을 사용하면 모든 엔드포인트 추가

management.endpoints.web.exposure.include=*

엔드포인트 제하기

▶ 특정 엔드포인트 제외

모든 엔드포인트 추가 후 특정 엔드포인트를 제외하고 싶은 경우 exclude를 통해 제

management.endpoints.web.exposure.exclude=<endpoint1>,<endpoint2>

구현하기

pom.xml 파일에 엑츄에이터 디펜던시 추가

앱을 구동하고 아래 경로로 이동하면 아래처럼 표시됨


특정 엔드포인트는 민감한 정보를 담고 있기 때문에 접근을 제한할 필요가 있습니다. 아래 링크를 클릭해서 보안기능을 추가합니다.

스프링 시큐리티 추가하기


이상으로 스프링 부트 엑츄에이터에 대해 알아보았습니다.


참조

◆ Actuator Endpoint List

Spring Boot Reference Documentation

 

Spring Boot Reference Documentation

This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe

docs.spring.io

728x90
반응형