마이크로서비스의 전류차단기(Circuit Breaker) 역할을 하는 오픈소스.
implementation 'io.micrometer:micrometer-registry-prometheus'
// application.yml
management:
endpoints:
web:
exposure:
include: refresh, health, beans, busrefresh, info, metrics, prometheus
http://127.0.0.1:{서비스port번호}/actuator/metrics
http://127.0.0.1:{서비스port번호}/actuator/prometheus
위 주소에서 모니터링을 할 수 있다.
// prometheus를 등록할 서비스를 입력한다.
...
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
- job_name: 'user-service'
scrape_interval: 15s
metrics_path: '/user-service/actuator/prometheus'
static_configs:
- targets: ['localhost:8000']
- job_name: 'order-service'
scrape_interval: 15s
metrics_path: '/order-service/actuator/prometheus'
static_configs:
- targets: ['localhost:8000']
- job_name: 'apigateway-service'
scrape_interval: 15s
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['localhost:8000']
API Gateway에 /{등록서비스명}/actuator/**
를 등록해둔다.
./prometheus --config.file=prometheus.yml
.\prometheus.exe
/bin/grafana-server
.\bin\grafana-server.exe