Spring Boot Actuator, Micrometer, Prometheus를 가지고 그라파나를 설정할 수 있게끔 할 거임.
- 📚 주요 기능:
/actuator/health → 시스템 상태 확인
/actuator/metrics → 다양한 메트릭(메모리 사용량, GC 횟수 등)
/actuator/env → 환경 변수 조회
/actuator/beans → 빈 정보 확인 등
management:
endpoints:
web:
exposure:
include: health, metrics, prometheus
만약에 false로 안 가져와도 되는 서브파티가 있다면
이렇게
management:
endpoints:
web:
exposure:
include: health, metrics, prometheus
server:
port: 9292
health:
elasticsearch:
enabled: false
- 📚 Micrometer가 수집하는 데이터 예시:
CPU 사용률
메모리 사용량
HTTP 요청 수
응답 시간
커스텀 메트릭(예: 서비스별 주문 수)
@Autowired
private MeterRegistry meterRegistry;
@PostConstruct
public void init() {
meterRegistry.counter("my.custom.counter").increment();
}
- 📚 특징:
Pull 기반 수집 (http://localhost:8080/actuator/prometheus)
PromQL로 자유로운 데이터 조회
Grafana 같은 시각화 툴과 통합 가능
https://alswns7984.tistory.com/63
# 📌 전역 설정
global:
scrape_interval: 15s # 메트릭을 수집할 기본 주기 (15초마다)
evaluation_interval: 15s # 알림 규칙 등을 평가하는 주기 (15초마다)
# 📌 Alertmanager 설정 (알림을 위한 구성, 지금은 비어 있음)
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093 # 알림 전송 대상 (지금은 비활성화됨)
# 📌 규칙 파일 (알림 조건 등을 정의하는 rule 파일, 지금은 사용 안 함)
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# 📌 메트릭 수집 대상 (scrape 설정)
scrape_configs:
# Prometheus 자기 자신을 모니터링하는 job
- job_name: "prometheus" # job 이름 (시계열 데이터에 라벨로 들어감)
# 기본 경로는 '/metrics'
# 기본 프로토콜은 'http'
static_configs:
- targets: ["localhost:9090"] # 수집할 대상 (Prometheus 서버 자신)
# 별도 job 설정 (예: 다른 애플리케이션)
- job_name: "job_onl"
# 기본 경로는 '/metrics'
static_configs:
- targets: ["localhost:9219"] # 수집할 대상 (9219 포트에서 메트릭 제공 중인 앱)
근데 우리는 지금 필요 없으니까
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: "spring-boot-app"
metrics_path: "/actuator/prometheus"
static_configs:
- targets: ["host.docker.internal:9292"] # 또는 localhost:8080 등 실제 actuator 포트