Spring Boot Admin Reference Guide
1. What is Spring Boot Admin?
Spring Boot Admin is a simple application to manage and monitor your Spring Boot Applications. The applications register
with our Spring Boot Admin Client (via http) or are discovered using Spring Cloud (e.g. Eureka). The UI is just an Angular.js application on top of the Spring Boot Actuator endpoints. In case you want to use the more advanced features (e.g. jmx-, loglevel-management),
Jolokia must be included in the client application.
2.
Getting started
2.1.
Set up admin server
First you need to setup your server. To do this just setup a simple boot project (using start.spring.io for example).
Add Spring Boot Admin Server and the UI to your dependencies:
pom.xml<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.3.3</version>
</dependency>Pull in the Boot Admin Server configuration via adding
@EnableAdminServerto
your configuration:@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class SpringBootAdminApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootAdminApplication.class, args);
}
}
| If you want to setup the Spring Boot Admin Server via war-deployment in a servlet-container, please have a look at the spring-boot-admin-sample-war. |
See also the spring-boot-admin-sample project.
2.2.
Register client applications
To register your application at the admin server (next referred as "clients"). Either you can include the spring-boot-admin client
or use Spring Cloud Discovery (e.g. Eureka)
2.2.1.
Register clients via spring-boot-admin-client
Each application that want to register itself to the admin has to include the Spring Boot Admin Client.
Add spring-boot-admin-starter-client to your dependencies:
pom.xml<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>1.3.3</version>
</dependency>Trigger the contained AutoConfiguration and tell the client where to find the admin to register at:
application.propertiesspring.boot.admin.url=http://localhost:8080
2.2.2.
Discover clients via Spring Cloud Discovery
If you already using Spring Cloud Discovery for your applications you don’t have to add the Spring Boot Admin Client to your applications. Just make the Spring Boot Admin Server a DiscoveryClient, the rest is done by our AutoConfiguration. The following steps
are for using Eureka. Also have a look at the Spring Cloud Netflix documentation.
Add spring-cloud-starter-eureka to you dependencies:
pom.xml<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.0.6.RELEASE</version>
</dependency>Enable discovery by adding
@EnableDiscoveryClientto
your configuration:@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableAdminServer
public class SpringBootAdminApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootAdminApplication.class, args);
}
}Tell the Eureka client where to find the service registry:
application.propertieseureka.instance.client.serviceUrl.defaultZone: http://localhost:8761/eureka/
See also spring-boot-admin-sample-discovery.
You can include the Spring Boot Admin to your Eureka server. Add the dependencies, add@EnableAdminServer toyour configuration and set spring.boot.admin.context-path tosomething different than "/" so that theSpring Boot Admin Server UI won’t clash with Eureka’s one. |
3.
Client applications
3.1.
Show version in application list
To get the version show up in the admin’s application list you have to set info.version.
For example using maven filtering during the build:
info.version=@project.version@
3.2.
JMX-bean management
To interact with JMX-beans in the admin UI you have to include Jolokia in your application. In case you are using thespring-boot-admin-starter-client it
will be pulled in for you, if not add Jolokia to your dependencies:
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
3.3.
Loglevel managment
Currently the loglevel management is only available for Logback. It is accessed via JMX so include
Jolokia in your application. In addition you have configure Logback’s JMXConfigurator:
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<jmxConfigurator/>
</configuration>
In case you are deploying multiple applications to the same JVM and multiple Logback-JMX-beans are present, the UI will select the JMXConfigurator with the context-name equals to your applications name. In this case you need to set the contextName inyour logback-configuration. |
3.4.
Spring Boot Admin Client
The Spring Boot Admin Client registers the application at the admin server. This is done by periodically doing a http post-request to the admin server providing informations about the application. It also adds Jolokia to your dependencies, so that JMX-beans
are accessible via http, this is needed if you want to manage loglevels or JMX-beans via the admin UI.
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.client.enabled |
Enables the Spring Boot Admin Client. |
|
|
spring.boot.admin.url |
List of URLs of the Spring Boot Admin server to register at. This triggers the AutoConfiguration. Mandatory. |
|
|
spring.boot.admin.api-path |
Http-path of registration endpoint at your admin server. |
|
|
spring.boot.admin.username spring.boot.admin.password |
Username and password for http-basic authentication. If set the registration uses http-basic-authentication when registering at the admin server. |
|
|
spring.boot.admin.period |
Interval for repeating the registration (in ms). |
|
|
spring.boot.admin.auto-registration |
If set to true the periodic task to register the application is automatically scheduled after the application is ready. |
|
|
spring.boot.admin.auto-deregistration |
Switch to enable auto-deregistration at Spring Boot Admin server when context is closed. |
|
|
spring.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 |
|
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, |
|
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, |
|
spring.boot.admin.client.name |
Name to register with. |
|
|
spring.boot.admin.client.prefer-ip |
Use the ip-address rather then the hostname in the guessed urls. If |
|
4.
Spring Boot Admin Server
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.context-path |
The context-path prefixes the path where the Admin Server’s statics assets and API should be served. Relative to the Dispatcher-Servlet. |
|
|
spring.boot.admin.monitor.period |
Time interval in ms to update the status of applications with expired status-informations. |
10.000 |
|
spring.boot.admin.monitor.status-lifetime |
Lifetime of application statuses in ms. The applications /health-endpoint will not be queried until the lifetime has expired. |
10.000 |
4.1.
Spring Cloud Discovery support
The Spring Boot Admin Server is capable of using Spring Clouds DiscoveryClient to
discover applications. The advantage is that the clients don’t have to include the spring-boot-admin-starter-client.
You just have to add a DiscoveryClient to your admin server - everything else is done by AutoConfiguration. The setup is explained above.
4.1.1.
Usage of discovery informations
The informations from the discovered services are converted by the ServiceInstanceConverter.
Spring Boot Admin ships with a default and Eureka converter implementation. The correct one is selected by AutoConfiguration. You can use your own conversion by implementing the interface and adding the bean to your application context.
When Eureka discovery is active, the EurekaServiceInstanceConverter willuse the discovered instances' homePageUrl and healthCheckUrl.In case the instances' managment.context-path isdifferent from the homePageUrl you shouldadd an entry management.context-path tothe instances' metadata-map with the correspondingvalue. |
When the default conversion kicks in, you can use the spring.boot.admin.discovery.converter.*propertiesto control the conversion for all your instances. |
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.discovery.enabled |
Enables the DiscoveryClient-support for the admin server. |
|
|
spring.boot.admin.discovery.management.context-path (deprecated) |
If set this will be appended to the service-url from the discovery information. |
|
|
spring.boot.admin.discovery.converter.management-context-path |
Will be appended to the service-url of the discovered service when the managment-url is converted by the |
|
|
spring.boot.admin.discovery.converter.health-endpoint |
Will be appended to the management-url of the discovered service when the health-url is converted by the |
|
4.2.
Hazelcast support
Spring Boot Admin Server supports cluster replication with Hazelcast. It is automatically enabled when aHazelcastConfig-
or HazelcastInstance-Bean is present. You
can also configure the Hazelcast instance to be persistent, to keep the status over restarts. Also have a look at the Spring
Boot support for Hazelcast.
Add Hazelcast to your dependencies:
pom.xml<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>Instantiate a HazelcastConfig:
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class SpringBootAdminApplication {
@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 static void main(String[] args) {
SpringApplication.run(SpringBootAdminApplication.class, args);
}
}
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.hazelcast.enabled |
Enables the Hazelcast support |
|
|
spring.boot.admin.hazelcast.application-store |
Name of the Hazelcast-map to store the applications |
|
|
spring.boot.admin.hazelcast.event-store |
Name of the Hazelcast-list to store the events |
|
4.3.
Notifications
4.3.1.
Mail notifications
Configure a JavaMailSender using spring-boot-starter-mail and
set a recipient.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
spring.mail.host=smtp.example.com
spring.boot.admin.notify.mail.to=admin@example.com
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.notify.mail.enabled |
Enable mail notifications |
|
|
spring.boot.admin.notify.mail.ignore-changes |
Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed. |
|
|
spring.boot.admin.notify.mail.to |
Comma-delimited list of mail recipients |
|
|
spring.boot.admin.notify.mail.cc |
Comma-delimited list of carbon-copy recipients |
|
|
spring.boot.admin.notify.mail.from |
Mail sender |
|
|
spring.boot.admin.notify.mail.subject |
Mail subject. SpEL-expressions are supported |
|
|
spring.boot.admin.notify.mail.text |
Mail body. SpEL-expressions are supported |
|
4.3.2.
Pagerduty notifications
To enable pagerduty notifications you just have to add a generic service to your pagerduty-account and setspring.boot.admin.notify.pagerduty.service-key to
the service-key you received.
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.notify.pagerduty.enabled |
Enable mail notifications |
|
|
spring.boot.admin.notify.pagerduty.ignore-changes |
Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed. |
|
|
spring.boot.admin.notify.pagerduty.service-key |
Service-key to use for Pagerduty |
|
|
spring.boot.admin.notify.pagerduty.url |
The Pagerduty-rest-api url |
|
|
spring.boot.admin.notify.pagerduty.description |
Description to use in the event. SpEL-expressions are supported |
|
|
spring.boot.admin.notify.pagerduty.client |
Client-name to use in the event |
|
|
spring.boot.admin.notify.pagerduty.client-url |
Client-url to use in the event |
4.3.3.
Hipchat notifications
To enable Hipchat notifications you need to create an API token from you Hipchat account and set the appropriate configuration properties.
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.notify.hipchat.enabled |
Enable Hipchat notifications |
|
|
spring.boot.admin.notify.hipchat.ignore-changes |
Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed. |
|
|
spring.boot.admin.notify.hipchat.url |
The HipChat REST API (V2) URL |
|
|
spring.boot.admin.notify.hipchat.auth-token |
The API token with access to the notification room |
|
|
spring.boot.admin.notify.hipchat.room-id |
The ID or url-encoded name of the room to send notifications to |
|
|
spring.boot.admin.notify.hipchat.notify |
Whether the message should trigger a user notification |
|
|
spring.boot.admin.notify.hipchat.description |
Description to use in the event. SpEL-expressions are supported |
|
4.3.4.
Slack notifications
To enable Slack notifications you need to add a incoming Webhook under custom integrations on your Slack account and configure it appropriately.
| Property name | Description | Default value |
|---|---|---|
|
spring.boot.admin.notify.slack.enabled |
Enable Slack notifications |
|
|
spring.boot.admin.notify.slack.ignore-changes |
Comma-delimited list of status changes to be ignored. Format: "<from-status>:<to-status>". Wildcards allowed. |
|
|
spring.boot.admin.notify.slack.webhook-url |
The Slack Webhook URL to send notifications |
|
|
spring.boot.admin.notify.slack.channel |
Optional channel name (without # at the beginning). If different than channel in Slack Webhooks settings |
|
|
spring.boot.admin.notify.slack.icon |
Optional icon name (without surrounding colons). If different than icon in Slack Webhooks settings |
|
|
spring.boot.admin.notify.slack.username |
Optional username to send notification if different than in Slack Webhooks settings |
|
|
spring.boot.admin.notify.slack.message |
Message to use in the event. SpEL-expressions and Slack markups are supported |
|
4.3.5.
Reminder notifications
To get reminders for down/offline applications you can add a RemindingNotifier to
your ApplicationContext. TheRemindingNotifier uses
another Notifier as delegate to send the
reminders.
@Configuration
@EnableScheduling
public class ReminderConfiguration {
@Autowired
private Notifier notifier;
@Bean
@Primary
public RemindingNotifier remindingNotifier() {
RemindingNotifier remindingNotifier = new RemindingNotifier(notifier);
remindingNotifier.setReminderPeriod(TimeUnit.MINUTES.toMillis(5));
return remindingNotifier;
}
@Scheduled(fixedRate = 6000L)
public void remind() {
remindingNotifier().sendReminders();
}
}
| The reminders will be sent every 5 minutes. | |
| Schedules sending of due reminders every 60 seconds. |
5.
FAQs
Can I include spring-boot-admin into my business application?
tl;dr You can, but you shouldn’t.
You can setspring.boot.admin.context-pathto
alter the path where the UI and REST-API is served, but depending on the complexity of your application you might get in trouble. On the other hand in my opinion it makes no sense for an application to monitor itself. In case your application goes down your
monitoring tool also does.How do I customize the UI?
You can only customize the UI by copying and modifying the source of
spring-boot-admin-uiand
adding your own module to your classpath.
Spring Boot Admin Reference Guide的更多相关文章
- Spring Boot Admin 的使用 2
http://blog.csdn.net/kinginblue/article/details/52132113 ******************************************* ...
- Spring Boot Admin的使用
http://www.jianshu.com/p/e20a5f42a395 ******************************* 上一篇文章中了解了Spring Boot提供的监控接口,例如 ...
- spring boot admin
这里记录一个spring cloud的模板,有的模块spring cloud eureka + spring boot admin + spring cloud zuul + 一个普通spring c ...
- spring boot admin + spring boot actuator + erueka 微服务监控
关于spring boot actuator简单使用,请看 简单的spring boot actuator 使用,点击这里 spring boot admin 最新的正式版本是1.5.3 与 spri ...
- Spring Boot admin 2.0 详解
一.什么是Spring Boot Admin ? Spring Boot Admin是一个开源社区项目,用于管理和监控SpringBoot应用程序. 应用程序作为Spring Boot Admin C ...
- Spring boot admin 节点状态一直为DOWN的排查
项目中需要监控各个微服务节点的健康状态,找到了spring boot admin这个全家桶监控工具,它其实是Vue.js美化过的Spring Boot Actuator,官方的解释是: codecen ...
- SpringCloud(8)微服务监控Spring Boot Admin
1.简介 Spring Boot Admin 是一个管理和监控Spring Boot 应用程序的开源软件.Spring Boot Admin 分为 Server 端和 Client 端,Spring ...
- Spring Boot Admin 的使用
Spring Boot 版本: 1.5.20 一.Spring Boot Admin Server 1.在pom.xml中增加 <dependency> <groupId>or ...
- 物联网架构成长之路(30)-Spring Boot Admin微服务WebUI监控
0. 前言 一个完整的微服务解决方案包含了许多微服务,基于我们需要观察各个微服务的运行状态,因此Spring Boot 生态提供了Spring Boot Admin 这个组件来实现微服务管理WEB U ...
随机推荐
- 查看SQLServer数据库信息的SQL语句
--查看数据库中的表信息, --包括(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_MSForEachTable @precommand=N'create table # ...
- selenium css(转)
如果button上有class属性的,如: <button id="ext-eng=1026" class="x-right-button"...&g ...
- Responsive Design响应式网站设计心得笔记
这个词已经喊了很久了,一直都是小打小闹,没正经的做过大的响应式全站,这次终于有机会了.网站刚上线半个月,就要改版为响应式设计,支持手机/PC等各类终端显示浏览.今天把首页做好,并测试无误,这里把一些应 ...
- MapReuce 编程总结-多MapReduce执行
学习hadoop,必不可少的就是写MapReduce程序,当然,对于简单的分析程序,我们只需一个MapReduce就能搞定,这里就不提单MapReuce的情况了,网上例子很多,大家可以百度Google ...
- 收集的jquery插件
1.精美jQuery分页插件 带滑动条分页使用HTML5实现刮刮卡效果 今天开始我们来收集一些jQuery分页插件,今天第一款jQuery分页插件适用于长翻页列表的分页应用,因为这款分页插件带有滑动条 ...
- Windows Azure 社区新闻综述(#73 版)
欢迎查看最新版本的每周综述,其中包含有关云计算和 Windows Azure的社区推动新闻.内容和对话. 以下是过去一周基于您的反馈汇集在一起的内容: 文章.视频和博客文章 · Windows A ...
- MFC解决Static控件背景透明时文本覆盖重影
通过映射OnCtlColor消息,而后在该函数中使用pDC->SetBkMode(TRANSPARENT)使Static控件背景透明时会出现:文本覆盖重影的问题,当改变控件的文本就会发生新文本与 ...
- Sencha Touch 2 结合HTML5的本地存储创建数据库实现增、删、改、查
大家好!我是范范.本人刚接触ST2到现在刚刚两个月,6月1号接的项目,那时才知道有Sencha Touch2这个东西,到现在两个月了期间的幸酸就不说了.今天说说在项目中用到的HTML5的本地存储.可能 ...
- TCP的核心系列 — SACK和DSACK的实现(一)
TCP的实现中,SACK和DSACK是比较重要的一部分. SACK和DSACK的处理部分由Ilpo Järvinen (ilpo.jarvinen@helsinki.fi) 维护. tcp_ack() ...
- swift3.0基础语法(2)
变量/常量,元组声明 var aaa = 0;//声明变量aaa 首次赋值时自动解析为Int类型 var aaa:Int = 0;//声明Int类型变量aaa let aaa = 0;//声明常量aa ...