VIJ
VIJ

Reputation: 1636

Call actuator within controller Spring Boot

I am trying to expose a custom endpoint which internally calls spring actuator. but i am getting Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out.

    @GetMapping(value = "/${spring.application.name}/actuator/health")
    public ResponseEntity<Object> createUser() {
        ResponseEntity<Map> entity = this.restTemplate.getForEntity("http://localhost:" + this.port
                + "/actuator/health", Map.class);

        return new ResponseEntity<>(entity, HttpStatus.OK);
    }


Is there any way to make it work.

Upvotes: 1

Views: 3041

Answers (1)

Abhijit Sarkar
Abhijit Sarkar

Reputation: 24637

There’s no need to create your own endpoint, just set management.endpoints.web.base-path=${spring.application.name} in application.properties. See https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/html/production-ready-monitoring.html.

Upvotes: 1

Related Questions