Use Spring Boot Admin in detail

Spring Boot Admin Monitors Spring Boot-based applications. The official documentation is here (V1.3.4) : In this configuration, Spring Boot Admin serves as the Server, and other Spring Boot applications serve as clients. The Client “registers” its information with the Server, and we can see the status information of the “registered” Spring Boot application on the Server. XML


de. Codecentric
< artifactId > spring – the boot – admin – server < / artifactId > < version > 1.3.4 < / version > < / dependency > < the dependency >

de.codecentric


spring-boot-admin-server-ui
The < version > 1.3.4 < / version > < / dependency >

2.1.2 Enabling Monitoring Add @enableadMinServer annotation to enable monitoring @Configuration@EnableAutoConfiguration @enableadMinServerPublic Class SpringBootAdminApplication { public static void main(String[] args) { SpringApplication.run(SpringBootAdminApplication.class, args); }}

The port on which the Server runs is not specified. The default port is 8080. If you want to specify this port, you need to set application.properties server.port=8080 in the application.properties file

XML


de. Codecentric
< artifactId > spring – the boot – admin – starter – client < / artifactId > < version > 1.3.4 < / version > < / dependency >

The spring-boot-admin-starter-client here automatically relies on Jolokia-core, which is used for JMX-bean management. 2.2.2 trigger automatic configuration and specify Server registration address application.properties spring.boot.admin.url=http://localhost:8080

In 3.1.2 above, we used the default port 8080 for the Server, so we declare the Server address as: http://localhost:8080 2.3 Start management Start the Server and Client and enter the Server address in the browser. http://localhost:8080 to see the Spring Boot application information “registered” in. To display the version number of managed applications in Spring Boot Admin’s application management list, you need to set info.version, for example, to Maven Filtering: application.properties [email protected]@

Set the version number displayed to the build version number in Maven POM.xml. Jolokia is used for jmx-bean management. Spring-boot-admin-starter-client automatically relies on Jolokia-core, so there is no need to display the dependencies. In the eureka-based discovery configuration in Section 3, we need to explicitly rely on: pom.xml


org.jolokia


jolokia-core

2.6 Loglevel management currently, Loglevel management is implemented only by Logback using JMX, so you need to rely on jolokia. We also need to configure JMXConfigurator for Logback: logback.xml



XML in the same directory as application.properties. If logback is not configured, Spring Boot Admin cannot manage the logging level of the application. 2.7, the Server monitoring itself above configuration, basically can work well. There is a problem, however, that we are not monitoring the Spring Boot Admin itself as the Server. To monitor the Server itself, configure the Server as a Client: configure steps 2.2.1, 2.2.2, 2.4, 2.6 on the Server. The example Spring Cloud project uses Eureka for registration/discovery. The Github example includes configurations based on Consul and Zookeper. Once configured, Spring Boot Admin can manage all applications registered with Eureka Server, including Spring Boot Admin itself (because it will also be registered with Eureka Server). 3.1, a simple Eureka Server About the Eureka Server will not be introduced in detail, just list the configuration process: pom.xml


org.springframework.cloud


spring-cloud-starter-eureka-server

EurekaServer startup class @SpringBootApplication@EnableEurekaServerpublic class EurekaServerApplication {public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); }}

application.properties

spring.application.name=eureka-serverserver.port=8761

Create a new bootstrap.properties file in the application.properties directory: bootstrap.properties eureka.instance.hostname=localhosteureka.client.registerWithEureka=falseeureka.client.fetchRegistry=falseeureka.client.s erviceUrl.defaultZone=http://

This file works much the same as application.properties, but only when the Application Context is started. Like application.properties but for the bootstrap phase of an application context. The above configuration shows that our Eureka Server is running on port 8761. Services registered address is: http://localhost:8761/eureka/ 3.2, the Server end official sample: Spring-boot-admin-sample-eureka


de.codecentric


spring-boot-admin-server
< version > 1.3.4 < / version > < / dependency > < the dependency > < groupId > DE. Codecentric < / groupId > < artifactId > spring – the boot – admin server – UI < / artifactId > < version > 1.3.4 < / version > < / dependency > < the dependency >

org.springframework.cloud


spring-cloud-starter-eureka

3.2.2. Add @enableDiscoveryClient to enable discovery @Configuration@EnableAutoConfiguration@EnableDiscoveryClient@EnableAdminServerpublic class SpringBootAdminApplication { public static void main(String[] args) { SpringApplication.run(SpringBootAdminApplication.class, args); }}

3.2.3, indicate where registration application. The properties eureka. Instance. Client. ServiceUrl. DefaultZone: http://localhost:8761/eureka/

That is the Eureka Server service address we configured in 3.1. When I test this configuration is not successful, instead of eureka. Client. ServiceUrl. DefaultZone: http://localhost:8761/eureka/ can, don’t know why. 3.2.4. The configuration from 3.2.1 to 3.2.3 will register the Server with Eureka Server, which means that Spring Boot Admin can also manage itself. However, the current configuration of the Server is not comprehensive (for example, the configuration of the Server is missing: Version information, JMX management, and Loglevel management). Add the following configuration: application.properties [email protected]@

pom.xml

<dependency> <groupId>org.jolokia</groupId> <artifactId>jolokia-core</artifactId></dependency>

logback.xml

<configuration> <include resource=”org/springframework/boot/logging/logback/base.xml”/> <jmxConfigurator/></configuration>

The configuration of the Client is mainly to register yourself in Eureka Server, so that you can be managed by Spring Boot Admin. Manual configuration of the Spring Boot Admin service address (section 2.2.2) is eliminated. 3.3.1, dependency pom. XML < dependency > < groupId > org. Springframework. Cloud < / groupId >

spring-cloud-starter-eureka



org.springframework.boot


spring-boot-starter-actuator

Note Add the spring-boot-starter-actuator dependency, because the application information is obtained through the related endpoints in the actuator. The spring-boot-admin-server relies on the spring-boot-admin-starter-client. The spring-boot-admin-starter-client relies on spring-boot-starter-actuator. 3.3.2 rainfall distribution on 10-12, start @ SpringBootApplication @ EnableEurekaClientpublic class ClientEurekaSampleApplication {public static void main(String[] args) { SpringApplication.run(ClientEurekaSampleApplication.class, args); }}

Add @enableDiscoveryClient or @Enableeurekaclient annotations to the startup class to register yourself with Erueka Server. 3.3.3, indicate where to register the bootstrap. Properties eureka. Client. ServiceUrl. DefaultZone: http://localhost:8761/eureka/

3.3.4 Set Application.properties [email protected]@ for other items

logback.xml

<configuration> <include resource=”org/springframework/boot/logging/logback/base.xml”/> <jmxConfigurator/></configuration>

pom.xml

<dependency> <groupId>org.jolokia</groupId> <artifactId>jolokia-core</artifactId></dependency>

Here is a Reminder of the email notification configuration (Pagerduty, Hipchat, Slack and Reminder). JavaMailSender Pop.xml


org.springframework.boot


spring-boot-starter-mail

application.properties

spring.mail.host=smtp.example.comspring.boot.admin.notify.mail.to=admin@example.com

Table: Mail Configuration Options [TD]

Explain the Property name Description Default value Chinese spring. The boot. Admin. Notify. Mail. Enabled the Enable E-mail notifications true enabled by Default spring.boot.admin.notify.mail.ignore-changes Comma-delimited list of status changes to be ignored. Format: Wildcards allowed. UNKNOWN:UP Indicates the status change notification that you want to ignore. A Comma spring. The boot. Admin. Notify. Mail. The to – delimited list of mail recipients “root @ localhost” receive notification email address, Commas spring. The boot. Admin. Notify. Mail. Cc – delimited list of carbon – copy recipients cc Spring. The boot. Admin. Notify. Mail. The from mail sender sends one spring. The boot. Admin. Notify. Mail. The subject mail subject. SpEL – expressions Are supported “# {application. The name} (# {application. Id}) is # {to.. the status}” theme spring. The boot. Admin. Notify. Mail. The text mail body. Spel-expressions are supported “#{application.name} (#{application.id})nstatus changed from #{from #{to.status}n #{application.healthUrl}”

Explain The Property name Description Default value Chinese spring. The boot. Admin. The context – The path to The context – path prefixes The path where The Admin Server’s statics assets and API should be served. Relative to the Dispatcher-Servlet. Admin Server Keep static access and API prefix (when you use in business applications, rather than when used alone, it is necessary to the) spring. The boot. Admin. The monitor. The period Time interval in ms to update the status of Applications with expired status-informations. 10.000 Frequency of updating application information, Spring unit milliseconds. Boot. Admin. The monitor. The status – lifetime lifetime of application statuses in Ms. The applications/health – The endpoint Will not be queried until the lifetime has expired. 10.000 The expiration time of your monitored application information, The state information from the discovered application is transformed by ServiceInstanceConverter. When automatically configured, Using Spring Boot Admin’s own Eureka conversion implementation. You can also implement the related interface and add it to the context instead of the default. Table: Register discovery configuration options [TD]

Explain the Property name Description Default value Chinese spring. The boot. Admin. Discovery. Enabled Enables the DiscoveryClient – support for The admin server. True, the default open spring. Boot. Admin. Discovery. The converter. The management – the context – the path Will be appended to the service-url of the discovered service when the managment-url is converted by the DefaultServiceInstanceConverter. spring.boot.admin.discovery.converter.health-endpoint Will be appended to the management-url of the discovered service When the health – the url is converted by the DefaultServiceInstanceConverter. “health” spring.boot.admin.discovery.ignored-services This services will be ignored when using discovery and not registered as application. Six, the attached: Spring Boot Admin Client Register with the Spring Boot Admin Server. The Client periodically sends Http posts to Admin to provide its own application information. If you need to manage Loglevels or JMX-Beans, add Jolokia to the dependency so that JMX-Beans can also be accessed over HTTP. Spring Boot Admin Client configuration options [TD]

Explain the Property name Description Default value Chinese spring. The boot. Admin. Client. Enabled Enables the spring boot admin client. True Url List of URLs of the Spring boot admin server to register at. This triggers the Autoconfiguration.mandatory. admin Specifies the server address list. This setting triggers automatic configuration. API -path http-path of registration endpoint at your admin server. “API /applications” register with admin Http server endpoint – path spring. The boot. Admin. The username spring. The boot. Admin. Password username and password for Http – basic authentication. If set the registration uses http-basic-authentication when registering at the admin server. Password of the account registered to the admin server Spring.boot.admin. period Interval for repeating the registration (in ms). 10.000 Specifies the retry Interval spring.boot.admin.auto-registration If set to true the periodic task to register the application is automatically Scheduled Scheduled After the application is ready. true Periodic registration tasks are automatically performed after application startup spring.boot.admin.auto-deregistration Switch to enable Auto-deregistration at Spring Boot Admin server when context is closed. Cancelled automatically registered spring. The boot. Admin. Client. Health – url client – health – url to register with. Can be overridden in case the reachable URL is different (e.g. Docker). Must be unique in registry. Guessed based on management-url and endpoints.health.id. spring.boot.admin.client.management-url Client-management-url to register with. Can be overridden in case the reachable url is different (e.g. Docker). Guessed based on service-url, server.servlet-path, management.port and management.context-path. spring.boot.admin.client.service-url Client-service-url to register with. Can be overridden in case the reachable url is different (e.g. Docker). Guessed based on hostname, server.port and server.context-path. spring.boot.admin.client.name Name to register with. ${spring.application.name} if The set, otherwise “spring – the boot – application”. When registering the name of the spring. The boot. Admin. Client. — – Use the IP – the IP address rather then the hostname in the guessed urls. If server.address / management.address is set, it get used. Otherwise the IP address returned from InetAddress.getLocalHost() gets used. false