💡 최신 Spring Cloud 버전에서는 Turbine, Hystrix가 아닌 Micrometer 라이브러리를 소개하고 있다.
모니터링?
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus'
management:
endpoint:
web:
exposure:
include: info, prometheus, metrics
@GetMapping("/health_check")
@Timed(value="users.status", longTask = true)
public String status() {
return String.format("It's Working in User Service"
+ ", port(local.server.port)=" + env.getProperty("local.server.port")
+ ", port(server.port)=" + env.getProperty("local.server.port")
+ ", token secret=" + env.getProperty("token.secret")
+ ", token expiration time=" + env.getProperty("token.expiration_time"));
}
@GetMapping("/welcome")
@Timed(value="users.welcome", longTask = true)
public String welcome() {
// return env.getProperty("greeting.message");
return greeting.getMessage();
}
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'user-service'
scrape_interval: 15s
metrics_path:; '/user-service/actuator/prometheus'
static_configs:
- targets: ['localhost:8000']
실행하기 위해서는 prometheus 실행파일을 실행하면 된다.
생략