- 설치 명령어 참고
mkdir -p grafana/data grafana/config
touch grafana/config/grafana.ini
vi docker-compose.yml
docker-compose up –d
docker-compose logs
docker ps (또는 docker-compose ps 로 실행된 컨테이너 확인)
ss –nltp (실행된 프로세스 포트 확인)
- 접속 확인
예 : http://[target ip]:3000/
초기 ID/PW : admin/admin
- docker-compose.yml에 추가
java:
image: joypark9/o11y-sample-app:latest
container_name: sample-app
user: "root"
ports:
- 8888:8888
restart: always
network_mode: host
- prometheus.yml에 추가
- job_name: 'sample_app'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['localhost:8888']
- 실행
docker-compose up –d
-
지표 확인
예 : http://[target ip]:8888/actuator/prometheus -
Grafana.com 제공되는 JVM 대시보드 추가
https://grafana.com/grafana/dashboards/4701
대시보드 ID : 4701 -
Spring boot application 설정 참고
# Dependency 추가 (build.gradle)
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
}
# prometheus endpoint 노출 (application.yml)
management:
endpoints:
web:
exposure:
include: "prometheus"