개발/spring

[actuator] prometheus 설정하기

방푸린 2022. 3. 17. 11:35
반응형

이전 글: 2022.01.28 - [개발/spring] - [actuator] git info를 health에 포함하기

 

[actuator] git info를 health에 포함하기

환경: java11, springboot2.6.2, gradle7.1 spring actuator? 스프링 부트 기반의 애플리케이션에서 제공하는 여러가지 정보를 쉽게 모니터링하게 하는 라이브러리 DB연결상태, disk space, rabbit, reddis, 커스..

bangpurin.tistory.com

 

이전에 프로젝트에 actuator를 적용하여 /health url을 통해 배포된 소스의 해쉬, 브랜치, 잘 떠있는지 유무 등을 알 수 있었다. 

스프링 actuator는 metrics를 통해 애플리케이션의 현 자원 상태(스레드 풀 상태, db 커넥션 상태, jvm gc상태 등)를 알 수 있게 하는데, 이를 주기적으로 요청하여 그 흐름을 관찰할 수도 있다. 특히 스프링에서 지원하는 prometheus를 추가적으로 설정하면 prometheus서버가 원하는 포맷으로 변환해주기 때문에 쉽게 prometheus서버와 연동이 가능하다.

 

오늘은 서비스 모니터링에 주로 쓰이는 prometheus를 추가적으로 설정해본다.

이전 글에서 설정한 그대로 작업 시작한다.

 

1. gradle build에 추가

//기존에 있었음
implementation 'org.springframework.boot:spring-boot-starter-actuator'
//actuator prometheus 추가
implementation("io.micrometer:micrometer-registry-prometheus")

 

2. application.properties 추가

//prometheus 추가
management.endpoints.web.exposure.include=health, shutdown, info, prometheus
//이미 있었음
management.endpoint.health.enabled=true
//추가
management.endpoint.prometheus.enabled=true

 

이렇게 하고 서버를 재시작하면 /actuator/prometheus 가 활성화된다.

/actuator/prometheus

 

이외 추가적인 정보에 대한 설정은 prometheus.yml을 생성하여 작성하면 된다.


참고

https://pyxispub.uzuki.live/?p=1810 

 

Spring Boot + Actuator + Micrometer로 Prometheus 연동하기

이제까지 블로그에서 Prometheus, Grafana 에 대해 여러 번 다룬 적이 있었다. Monitoring with cAdvisor + Prometheus + Grafana (https://pyxispub.uzuki.live/?p=1764)Alert with Grafana(https://pyxispub.uzuki.live/?p=1779) 두번째 글 까

pyxispub.uzuki.live

https://happycloud-lee.tistory.com/217

 

[SC11] Spring Boot Actuator 이란 ?

1. Spring Boot Actuator 이해 1) WHY? 각 마이크로서비스는 고유의 목적을 가지고 개발되고 운영됩니다. 하지만 모든 마이크로서비스에는 공통으로 요구되는 기능이 있습니다. 예를 들어 Health Check와 상

happycloud-lee.tistory.com

 

728x90
반응형