- Spring Boot Actuator
- Prometheus
- Grafana
- 포트 정리
- 관계와 데이터 흐름
- /actuator/prometheus vs Grafana
Spring Boot에서 애플리케이션의 내부 상태 및 메트릭 데이터를 노출해주는 라이브러리.
애플리케이션의 헬스 체크, HTTP 요청/응답 기록, DB 커넥션 풀, 쓰레드 풀, 등록된 빈 등 다양한 정보를 REST API 형태로 제공함.
서버나 애플리케이션의 상태(성능 지표)를 시간에 따라 수집한 데이터.
프로메테우스가 이 데이터를 시계열 데이터(Time Series) 형태로 저장해서 시간에 따른 변화를 분석 가능.
management:
endpoints:
web:
exposure:
include: health,info,prometheus
metrics:
export:
prometheus:
enabled: true
management.endpoints.web.exposure.include: 외부로 노출할 엔드포인트 설정 (보안을 위해 꼭 필요한 것만 열어줘야 함) management.metrics.export.prometheus.enabled: 프로메테우스가 수집할 데이터 포맷을 활성화시킴. 없어도 됨. (default: true)결론적으로 endpoint를 사용하려면 활성화하고 노출시켜줘야 함
시계열(Time Series) 데이터베이스.
Actuator가 제공하는 메트릭 데이터를 주기적으로 수집함. (Pull 방식)
JVM 메모리, CPU 사용량, HTTP 요청, DB 커넥션 풀 상태 등 다양한 지표를 시계열로 저장해서 분석할 수 있음.
# ./prometheus.yml
global:
scrape_interval: 5s
scrape_configs:
- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['host.docker.internal:8080']
scrape_interval 로 메트릭을 수집해 DB에 저장프로메테우스가 수집한 메트릭 데이터를 시각화하는 대시보드 도구.
여러 지표를 한눈에 보고 성능 변화 추세, 병목 현상 등을 직관적으로 파악할 수 있음.
실질적인 모니터링은 그라파나를 통해 확인
| 포트 | 서비스 | 특징 및 설명 |
|---|---|---|
| 8080 | Spring Boot Actuator | 엔드포인트 제공 (/actuator/health, /actuator/prometheus) |
| 9090(기본포트) | Prometheus | 메트릭 쿼리, 수집 상태 확인 UI (Text 형식) |
| 3000(기본포트) | Grafana | 프로메테우스가 수집한 데이터로 대시보드 시각화 |
[Spring Boot App (8080)] < [Prometheus (9090)] < [Grafana (3000)]
| 단계 | 설명 |
|---|---|
| 1. Spring Boot Actuator | /actuator/prometheus 엔드포인트에서 JVM 메모리, DB 커넥션, HTTP 요청 등 실시간 데이터를 Prometheus 형식으로 노출 |
| 2. Prometheus | /actuator/prometheus에 주기적으로 HTTP GET 요청을 보내 데이터를 수집 후 DB에 저장 |
| 3. Grafana | Prometheus 데이터를 가져와 시각화 (그래프, 차트, 테이블) |
| 항목 | /actuator/prometheus (8080) | Grafana (3000) |
|---|---|---|
| 데이터 | 실시간 Raw 데이터 | Prometheus DB에서 가져온 시계열 데이터 |
| 특징 | 텍스트 형태, 개발자 전용 | 그래프/차트로 시각화 |
| 목적 | Prometheus가 데이터 수집 | 벤치마킹 대시보드, 알림, 분석 |