Java & Spring
자바 모니터링 설정
닥치고개돌
2024. 1. 30. 12:43
728x90
맥os 환경에서 모니터링 설정하기
각각 설정해줄 부분은 스프링부트설정, 프로메테우스 설정, 그라파나 설정이다
모니터링 시스템은 기본적으로 로그발생 => 데이터 수집 => 통합 => 시각화의 단계로 되어있다.

스프링부트
actuator 설정 - (metrics 출력을 위해)
- build.gradle
-
implementation 'org.springframework.boot:spring-boot-starter-actuator' runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
-
- application-{환경}.yml
- management:
health:
db:
enabled: false
endpoints:
web:
exposure:
include: health, info, metrics, prometheus
base-path: /v1/actuator
- management:
- => 보안상 prod환경은 안여는게 좋음
프로메테우스
brew install prometheus
vi /opt/homebrew/etc/prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'local'
metrics_path: '/v1/actuator/prometheus'
static_configs:
- targets: ['localhost:8080']
- job_name: 'spring--app'
metrics_path: '/v1/actuator/prometheus'
static_configs:
- targets: ['www.naver.com'] // 주소 입력
scheme: https # to use https instead of http for scraping
tls_config:
insecure_skip_verify: true # This is the key
brew services start prometheus
Status > Targets 페이지

그라파나
- brew update
- brew install grafana
- /opt/homebrew/Cellar/grafana/[version]
- brew services start grafana
- http://localhost:3000/
- 첫 로그인 admin / admin 으로 로그인
728x90