Search code examples
spring-boot-admin

How do I get instanceID when I use spring boot admin?


I want to integrate the springbootadmin monitoring detail page into our own management system, how can I get the instanceId of the detail page? for example localhost:8020/instances/5f3d1f8ee6a0/details,I want to know how can I get 5f3d1f8ee6a0


Solution

  • With ApplicationRegistrator class, you can create a route on the client exposing the registered id:

    @RestController
    @RequestMapping("api/instance")
    class InstanceController {
    
        @Autowired
        ApplicationRegistrator applicationRegistrator
    
        @GetMapping("/")
        String get() {
            return applicationRegistrator.getRegisteredId();
        }
    }