Java/Spring Boot

[Spring Boot] Actuator (HTTP/JMX)

hh_lin 2022. 5. 8. 19:55

1. Spring Actuator

  • 운영 중인 애플리케이션을 HTTP나 JMX를 이용해서 모니터링하고 관리할 수 있는 기능
  • org.springframework.boot:spring-boot-starter-actuator 의존성 추가

 

 

 

 

 

 

 

 

 

2. 애플리케이션의 각종 정보를 확인할 수 있는 Endpoints

  • 다양한 Endpoints 제공
  • JMX 또는 HTTP를 통해 접근 가능 함
  • 활성화 및 노출여부 설정 가능
  • shutdown을 제외한 모든 Endpoint는 기본적으로 활성화 상태
    Web은 health만 노출여부 활성화 상태 (JMX는 거의 대부분이 활성화 상태)
  • 활성화 옵션 조정
    • management.endpoints.enabled-by-default=false
    • management.endpoint.info.enabled=true

 

 

 

 

 

 

 

 

 

3. HTTP에서 endpoint 확인하기

  • application 실행 후 localhost:8080/actuator 접속
  • HATEOAS (현재 리소스와 연관되어 있는 링크 정보) 
  • 공개된 정보는 helath 밖에 없음

 

2022.04.03 - [Java/Spring & Spring Boot] - [Spring Boot] Spring HATEOAS

 

[Spring Boot] Spring HATEOAS

1. HATEOAS Hypermedia As The Engine Of Application State 서버: REST API에서 리소스에 대한 정보를 제공할 때, 현재 리소스와 연관된 링크 정보를 클라이언트에게 제공한다. 클라이언트: 연관된 링크 정보를..

hhlin.tistory.com

 

 

 

 

 

 

 

 

4. JMX에서 endpoint 확인하기

① JConsole 사용하기

 

 

 

 

 

 

 

 

 

② VisualVM 사용하기

  • Java 10 부터 JVM에 VisualVM이 포함되어 있지 않음
  • https://visualvm.github.io/download.html 에서 설치 필요
  • JConsole과 비슷하지만, plugin이 있어서 더 다양한 정보를 제공하고 보기가 더 편함
  • Tools - Plugins - Available Plugins 에서 VisualVM-MBeans 설치해야 MBeans 탭이 생김

 

 

 

 

 

 

③ HTTP 사용하기

  • JConsole, VisualVM 말고 웹으로 보고 싶은 경우, 모든 endpoint를 노출 활성화로 변경
  • localhost:8080/actuator 접속
  • 외부로 노출되면 안되기 때문에 admin만 접근할 수 있도록 spring-security 적용필요
  • health와 info를 제외한 대부분의 Endpoint가 기본적으로 비공개 상태
  • 공개 옵션 조정
    • management.endpoints.web.exposure.include=*
    • management.endpoints.web.exposure.exclude=env,beans

 

 

 

 

 

 

 

 

 

 

https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A%B8/dashboard

 

스프링 부트 개념과 활용 - 인프런 | 강의

스프링 부트의 원리 및 여러 기능을 코딩을 통해 쉽게 이해하고 보다 적극적으로 사용할 수 있는 방법을 학습합니다., - 강의 소개 | 인프런...

www.inflearn.com

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-endpoints

 

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

https://kotlinworld.com/309

 

JConsole을 활용한 Java Process Code Cache 모니터링

JConsole이란? JConsole이란 실행중인 java process를 모니터링 하는 응용프로그램으로, jdk에 포함되어 나온다. 응용프로그램이어서 실행하면 바로 사용할 수 있다. 윈도우에서 사용하기 위해 필요한 사

kotlinworld.com