프로메테우스 설치
프로메테우스 폴더 내부에 있는 yaml 파일 설정
# my global config
global:
scrape_interval: 15s
evaluation_interval: 15s
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "spring-actuator" # 아무거나 가능
metrics_path: '/actuator/prometheus'
scrape_interval: 1s
static_configs:
- targets: [ 'localhost:8080' ]
prometheus.exe
로 프로메테우스 실행(터미널이 뜸)
SpringBoot 프로젝트에 의존성 추가 및 application.yaml 파일에 설정
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
management:
endpoints:
web:
exposure:
include: health, info, metrics, prometheus
localhost:9090 들어가서 확인
그라파나 설치
localhost:3000으로 그라파나 접속
DATA SOURCES 추가(Add data source : http://localhost:3000/datasources/new) → Prometheus 클릭
HTTP 부분에 http://localhost:9090 입력 후 맨 아래 HTTP method가 POST인지 확인 → 하단 Save & test 버튼 클릭
대시 보드 추가
💻 참고 사이트 : Spring Boot | Prometheus + Grafana 모니터링 :: venh.log (tistory.com)