spring-boot-admin
2019-01-28 19:20:17 34 举报
AI智能生成
spring-boot-admin 笔记
作者其他创作
大纲/内容
SBA Client
Registering client applications
Spring Boot Admin Client
Spring Cloud Discovery
Show version in application list
spring-boot-maven-plugin
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
JMX-bean management
Dependency
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
Loglevel management
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<jmxConfigurator/>
</configuration>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<jmxConfigurator/>
</configuration>
Spring Boot Admin Client
configuration options
spring.boot.admin.url
spring.boot.admin.username
spring.boot.admin.password
spring.boot.admin.username
spring.boot.admin.password
Instance metadata options
user.name
user.password
user.password
Security
Securing Spring Boot Admin Server
@Configuration
public static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// Page with login form is served as /login.html and does a POST on /login
http.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll();
// The UI does a POST on /logout on logout
http.logout().logoutUrl("/logout");
// The ui currently doesn't support csrf
http.csrf().disable();
// Requests for the login page and the static assets are allowed
http.authorizeRequests()
.antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**")
.permitAll();
// ... and any other request needs to be authorized
http.authorizeRequests().antMatchers("/**").authenticated();
// Enable so that the clients can authenticate via HTTP basic for registering
http.httpBasic();
}
}
public static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// Page with login form is served as /login.html and does a POST on /login
http.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll();
// The UI does a POST on /logout on logout
http.logout().logoutUrl("/logout");
// The ui currently doesn't support csrf
http.csrf().disable();
// Requests for the login page and the static assets are allowed
http.authorizeRequests()
.antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**")
.permitAll();
// ... and any other request needs to be authorized
http.authorizeRequests().antMatchers("/**").authenticated();
// Enable so that the clients can authenticate via HTTP basic for registering
http.httpBasic();
}
}
Securing Client Actuator Endpoints
Properties
spring.boot.admin.url: http://localhost:8080
spring.boot.admin.client.metadata.user.name: ${security.user.name}
spring.boot.admin.client.metadata.user.password: ${security.user.password}
Reference
http://codecentric.github.io/spring-boot-admin/1.5.7/
SBA Server
Getting Started
Dependency
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
Annotation
@EnableAdminServer
configuration options
spring.boot.admin.context-path
spring.boot.admin.monitor.period
10,000
spring.boot.admin.monitor.status-lifetime
10,000
spring.boot.admin.monitor.connect-timeout
2,000
spring.boot.admin.monitor.read-timeout
5,000
spring.boot.admin.routes.endpoints
"env", "metrics", "trace", "dump", "jolokia", "info", "configprops", "activiti", "logfile", "refresh", "flyway", "liquibase", "loggers"
spring.boot.admin.metadata-keys-to-sanitize
".password$", ".*secret$", ".*key$", ".$token$", ".credentials.", ".*vcap_services$"
Instance metadata options
Spring Cloud Discovery
Dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
Annotations
@EnableDiscoveryClient
Properties
eureka.client.serviceUrl.defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/
management.security.enabled: false
spring.boot.admin.discovery.ignored-services
spring.boot.admin.discovery.services
Clustering
Dependencies
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
Beans
@Bean
public Config hazelcastConfig() {
return new Config().setProperty("hazelcast.jmx", "true")
.addMapConfig(new MapConfig("spring-boot-admin-application-store").setBackupCount(1)
.setEvictionPolicy(EvictionPolicy.NONE))
.addListConfig(new ListConfig("spring-boot-admin-event-store").setBackupCount(1)
.setMaxSize(1000));
}
public Config hazelcastConfig() {
return new Config().setProperty("hazelcast.jmx", "true")
.addMapConfig(new MapConfig("spring-boot-admin-application-store").setBackupCount(1)
.setEvictionPolicy(EvictionPolicy.NONE))
.addListConfig(new ListConfig("spring-boot-admin-event-store").setBackupCount(1)
.setMaxSize(1000));
}
Properties
Hazelcast configuration options
Hazelcast configuration options
spring.boot.admin.hazelcast.enabled=true
spring.boot.admin.hazelcast.application-store="spring-boot-admin-application-store"
spring.boot.admin.hazelcast.event-store="spring-boot-admin-event-store"
Notifications
Reminder notifications
Notifier
RemindingNotifier
Filtering notifications
Notifier
FilteringNotifier
Mail notifications
Dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
Properties
spring.boot.admin.notify.mail.enabled=true
spring.boot.admin.notify.mail.ignore-changes="UNKNOWN:UP"
spring.boot.admin.notify.mail.to="root@localhost"
spring.boot.admin.notify.mail.to
spring.boot.admin.notify.mail.cc
spring.boot.admin.notify.mail.from
spring.boot.admin.notify.mail.subject="#{application.name} (#{application.id}) is #{to.status}"
spring.boot.admin.notify.mail.text="#{application.name} (#{application.id})\nstatus changed from #{from.status} to #{to.status}\n\n#{application.healthUrl}"
spring.boot.admin.notify.mail.ignore-changes="UNKNOWN:UP"
spring.boot.admin.notify.mail.to="root@localhost"
spring.boot.admin.notify.mail.to
spring.boot.admin.notify.mail.cc
spring.boot.admin.notify.mail.from
spring.boot.admin.notify.mail.subject="#{application.name} (#{application.id}) is #{to.status}"
spring.boot.admin.notify.mail.text="#{application.name} (#{application.id})\nstatus changed from #{from.status} to #{to.status}\n\n#{application.healthUrl}"
PagerDuty notifications
OpsGenie notifications
Hipchat notifications
Slack notifications
Let’s Chat notifications
Microsoft Teams notifications
Telegram notifications
UI Modules
Hystrix UI Module
Dependencies
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-hystrix</artifactId>
<version>1.5.7</version>
</dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-hystrix</artifactId>
<version>1.5.7</version>
</dependency>
Properties
spring.boot.admin.routes.endpoints
env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream
Turbine UI Module
Dependencies
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-turbine</artifactId>
<version>1.5.7</version>
</dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-turbine</artifactId>
<version>1.5.7</version>
</dependency>
Properties
spring.boot.admin.turbine.enabled
true
spring.boot.admin.turbine.clusters
default
spring.boot.admin.turbine.location
turbine
Activiti UI Module
Dependencies
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-activiti</artifactId>
<version>1.5.7</version>
</dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-activiti</artifactId>
<version>1.5.7</version>
</dependency>
Properties
pring.boot.admin.routes.endpoints
env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,activiti
Login UI Module
Dependencies
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-login</artifactId>
<version>1.5.7</version>
</dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-login</artifactId>
<version>1.5.7</version>
</dependency>
只提供了登陆页面和退出按钮
0 条评论
下一页