spring-boot-admin-docs/src/site/docs/01-getting-started/20-client-registration.md
To monitor your applications with Spring Boot Admin, they need to register with the Admin Server. There are three main approaches to achieve this:
The Spring Boot Admin Client library enables applications to register themselves directly with the Admin Server.
Add the Spring Boot Admin Client starter to your application:
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>@VERSION@</version>
</dependency>
For Gradle:
implementation 'de.codecentric:spring-boot-admin-starter-client:@VERSION@'
Add the Admin Server URL to your application.properties or application.yml:
spring:
boot:
admin:
client:
url: http://localhost:8080 # URL of your Admin Server
management:
endpoints:
web:
exposure:
include: "*" # Expose all actuator endpoints
endpoint:
health:
show-details: ALWAYS
info:
env:
enabled: true # Enable the info endpoint
spring.boot.admin.client.url=http://localhost:8080
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=ALWAYS
management.info.env.enabled=true
When your application starts, it will automatically register with the Admin Server. You'll see your application appear in the Admin Server's web interface.
Add custom metadata to your application registration:
spring:
boot:
admin:
client:
instance:
metadata:
tags:
environment: production
region: us-east-1
team: platform
Override the service URL that the Admin Server uses to connect:
spring:
boot:
admin:
client:
instance:
service-url: https://my-app.example.com
service-host-type: IP # or CANONICAL
Configure how often the client registers with the server:
spring:
boot:
admin:
client:
period: 10000 # milliseconds (default: 10000)
auto-registration: true # Enable/disable auto-registration
If you're using Spring Cloud Discovery (Eureka, Consul, Zookeeper), you don't need the Spring Boot Admin Client. The Admin Server can discover applications automatically.
Add to your application:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
leaseRenewalIntervalInSeconds: 10
health-check-url-path: /actuator/health
metadata-map:
startup: ${random.int} # Trigger info update after restart
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
Add Eureka client to your Admin Server:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
Enable discovery in the Admin Server:
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient
@EnableAdminServer
@SpringBootApplication
public class SpringBootAdminApplication {
static void main(String[] args) {
SpringApplication.run(SpringBootAdminApplication.class, args);
}
}
spring:
cloud:
consul:
discovery:
metadata:
user-name: ${spring.security.user.name}
user-password: ${spring.security.user.password}
:::warning
Consul does not allow dots (".") in metadata keys. Use dashes instead (e.g., user-name instead of user.name).
:::
For Zookeeper integration, see the spring-boot-admin-sample-zookeeper example.
You can configure applications statically on the Admin Server using Spring Cloud's SimpleDiscoveryClient.
spring:
cloud:
discovery:
client:
simple:
instances:
my-application:
- uri: http://localhost:8081
metadata:
management.context-path: /actuator
This approach is useful for:
When your Admin Server is secured, clients need credentials to register:
spring:
boot:
admin:
client:
url: http://localhost:8080
username: admin
password: secret
For more details, see Security.
Spring Boot Admin requires access to actuator endpoints. Ensure they are properly exposed:
management:
endpoints:
web:
exposure:
include: "*" # Expose all endpoints
# Or be more specific:
# include: health,info,metrics,env,loggers
:::warning In production, carefully consider which endpoints to expose and implement proper security measures. :::
After configuring your client:
http://localhost:8080)Check the logs for registration confirmation:
INFO: Application registered itself as <instance-id>