헬스 정보를 사용하면 애플리케이션에 문제가 발생했을 때 문제를 빠르게 인지할 수 있다.
http://localhost:8080/actuator/health
기본 동작

- 헬스 정보는 단순히 애플리케이션이 요청에 응답을 할 수 있는지 판단하는 것을 넘어서 애플리케이션이 사용하는 데이터베이스가 응답하는지, 디스크 사용량에는 문제가 없는지 같은 다양한 정보들을 포함해서 만들어진다
show-details 옵션
헬스 정보를 더 자세히 보려면 다음 옵션을 지정하면 된다.
management.endpoint.health.show-details=always
management:
endpoint:
health:
show-details: always #헬스체크 자세히 하는 옵션

- 각각의 항목이 아주 자세하게 노출되는 것을 확인할 수 있다.
show-components 옵션
자세하게 노출하는 것이 부담스럽다면 show-details 옵션을 제거하고 다음 옵션을 사용하면 된다.
management.endpoint.health.show-components=always
management:
endpoint:
health:
show-components: always

- 각 헬스 컴포넌트의 상태 정보만 간략하게 노출한다.
헬스 이상 상태
헬스 컴포넌트 중에 하나라도 문제가 있으면 전체 상태는 DOWN 이 된다.
{
"status": "DOWN",
"components": {
"db": {
"status": "DOWN"
},
"diskSpace": {
"status": "UP"
},
"ping": {
"status": "UP"
}
}
}
- 여기서는 db에 문제가 발생했다. 하나라도 문제가 있으면 DOWN으로 보기 때문에 이 경우 전체상태의 status 도 DOWN 이 된다.
참고로 액츄에이터는 db , mongo , redis , diskspace , ping과 같은 수많은 헬스 기능을 기본으로 제공한다.
Production-ready Features
You can enable recording of HTTP exchanges by providing a bean of type HttpExchangeRepository in your application’s configuration. For convenience, Spring Boot offers InMemoryHttpExchangeRepository, which, by default, stores the last 100 request-response
docs.spring.io
참고 - 헬스 기능 직접 구현하기
원하는 경우 직접 헬스 기능을 구현해서 추가할 수 있다. 직접 구현하는 일이 많지는 않기 때문에 필요한 경우 다음 공식 매뉴얼을 참고하자
Production-ready Features
You can enable recording of HTTP exchanges by providing a bean of type HttpExchangeRepository in your application’s configuration. For convenience, Spring Boot offers InMemoryHttpExchangeRepository, which, by default, stores the last 100 request-response
docs.spring.io
'스프링 부트(핵심 원리와 활용)' 카테고리의 다른 글
| Ch07. 액츄에이터 - 로거 (0) | 2023.03.29 |
|---|---|
| Ch07. 액츄에이터 - 애플리케이션 정보 (0) | 2023.03.29 |
| Ch07. 액츄에이터 - 다양한 엔드포인트 (0) | 2023.03.20 |
| Ch07. 액츄에이터 - 엔드포인트 설정 (0) | 2023.03.20 |
| Ch07. 액츄에이터 - 액츄에이터 시작 (0) | 2023.03.20 |