Spring Boot 2.X (XVII): The monitoring of the use and configuration of Spring Boot Admin

About Admin

Spring Boot Admin is Spring Boot application health monitoring and management backend interface. The latest rewrite UI using vue.js years.

Spring Boot Admin provides rich monitoring capabilities for operation and maintenance of applications registered. as follows:

  • Display health
  • For more information on runtime display applications, such as: JVM memory and indicators
  • And counter measure
  • Data source measure
  • Cache measure
  • Tracking and downloading log files
  • View jvm systems and environmental properties
  • A key management loglevel
  • Manage the implementation of JMX-beans
  • View thread dump
  • Viewing the Trace Information
  • Hystrix-Dashboard Integration (2.X version deleted integration)
  • Download heapdump
  • State Change Notification (support: e-mail, Slack, Hipchat, etc.)
  • State change event log (non-permanent)

More you can learn more by test documents.

Admin use and configure

Spring Boot Admin server

Project Dependencies

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- admin-server -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.1.6</version>
        </dependency>

Start Admin Server Configuration

@SpringBootApplication
@EnableAutoConfiguration
@EnableAdminServer
public class SpringBootAdminApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminApplication.class, args);
    }

}

application.properties Configuration

server.port=9000
spring.application.name=Spring Boot Admin Web

test

Start the project, http://127.0.0.1:9000 accessed through a browser

Spring Boot Admin Client

Here is the Spring Boot Actuator to the above project as an example

Project Dependencies

<!-- admin-client -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.1.6</version>
        </dependency>

application.properties Configuration

#设置 Admin Server 地址
server.port=8080
spring.application.name=Spring Boot Actuator Demo
spring.boot.admin.client.url=http://127.0.0.1:9000

test

Startup Items, browser access http://127.0.0.1:9000 through, we'll see Spring Boot Admin management interface applications will display the corresponding client application, click Apply to enter detailed monitoring interface.


Spring Boot Admin Configuration Properties

Spring Boot Admin Server configuration properties Detailed

Attributes description Defaults
spring.boot.admin.context-path The context of the path ahead should provide services for the Admin Server API static assets and path of the prefix. With respect to the Dispatcher-Servlet /
spring.boot.admin.monitor.status-interval 更新client端状态的时间间隔,单位是毫秒 10000
spring.boot.admin.monitor.status-lifetime client端状态的生命周期,该生命周期内不会更新client状态,单位是毫秒 10000
spring.boot.admin.monitor.connect-timeout 查询client端状态信息时的连接超时,单位是毫秒 2000
spring.boot.admin.monitor.read-timeout 查询client端状态信息时的读取超时时间,单位是毫秒 10000
spring.boot.admin.monitor.default-retries 失败请求的默认重试次数。Modyfing请求(PUT,POST,PATCH,DELETE)将永远不会重试 0
spring.boot.admin.monitor.retries.* 键值对,具有每个endpointId的重试次数。默认为默认重试。Modyfing请求(PUT,POST,PATCH,DELETE)将永远不会重试
spring.boot.admin.metadata-keys-to-sanitize 要被过滤掉的元数据(当与正则表达式相匹配时,这些数据会在输出的json数据中过滤掉) ".password$", ".secret$", ".key$", ".$token$", ".credentials.", ".*vcap_services$"
spring.boot.admin.probed-endpoints 要获取的client的端点信息 "health", "env", "metrics", "httptrace:trace", "threaddump:dump", "jolokia", "info", "logfile", "refresh", "flyway", "liquibase", "heapdump", "loggers", "auditevents"
spring.boot.admin.instance-proxy.ignored-headers 向client发起请求时不会被转发的headers信息 "Cookie", "Set-Cookie", "Authorization"
spring.boot.admin.ui.public-url 用于在ui中构建基本href的基本URL 如果在反向代理后面运行(使用路径重写),则可用于进行正确的自我引用。如果省略了主机/端口,将从请求中推断出来
spring.boot.admin.ui.brand 导航栏中显示的品牌 <img src="assets/img/icon-spring-boot-admin.svg"><span>Spring Boot Admin</span>
spring.boot.admin.ui.title 页面标题 "Spring Boot Admin"
spring.boot.admin.ui.favicon 用作默认图标的图标,用于桌面通知的图标 "assets/img/favicon.png"
spring.boot.admin.ui.favicon-danger 当一项或多项服务关闭并用于桌面通知时,用作网站图标 "assets/img/favicon-danger.png"

Spring Boot Admin Client 配置属性详解

属性 描述 默认值
spring.boot.admin.client.enabled 启用Spring Boot Admin Client true
spring.boot.admin.client.url 要注册的server端的url地址。如果要同时在多个server端口注册,则用逗号分隔各个server端的url地址
spring.boot.admin.client.api-path 管理服务器上注册端点的Http路径 "instances"
spring.boot.admin.client.username 如果server端需要进行认证时,该属性用于配置用户名
spring.boot.admin.client.password 如果server端需要进行认证时,该属性用于配置密码
spring.boot.admin.client.period 重复注册的时间间隔(以毫秒为单位) 10000
spring.boot.admin.client.connect-timeout 连接注册的超时时间(以毫秒为单位) 5000
spring.boot.admin.client.read-timeout 读取注册超时(以毫秒为单位) 5000
spring.boot.admin.client.auto-registration 如果设置为true,则在应用程序准备就绪后会自动安排注册应用程序的定期任务 true
spring.boot.admin.client.auto-deregistration 当上下文关闭时,切换为在Spring Boot Admin服务器上启用自动解密。如果未设置该值,并且在检测到正在运行的CloudPlatform时,该功能处于活动状态 null
spring.boot.admin.client.register-once 如果设置为true,则客户端将仅向一台管理服务器注册(由定义spring.boot.admin.instance.url);如果该管理服务器出现故障,将自动向下一个管理服务器注册。如果为false,则会向所有管理服务器注册 true
spring.boot.admin.client.instance.health-url 要注册的health-url地址。如果可访问URL不同(例如Docker),则可以覆盖。在注册表中必须唯一 默认该属性值与management-url 以及endpoints.health.id有关。比如工程中该值为:healthUrl=http://127.0.0.1:8080/actuator/health,其中http://127.0.0.1:8080/actuator是management-url,health是endpoints.health.id
spring.boot.admin.client.instance.management-base-url 用于计算要注册的管理URL的基本URL。该路径是在运行时推断的,并附加到基本URL 默认该属性值与management.port, service-url 以及server.servlet-path有关,如工程中该值为http://127.0.0.1:8080,其中8080端口是配置的获取actuator信息的端口。127.0.0.1是设置的service-url值,如果没有设置service-url的话,则为配置的server.servlet-path值(项目的启动路径)
spring.boot.admin.client.instance.management-url 要注册的management-url。如果可访问的URL不同(例如Docker),则可以覆盖 默认该属性值与management-base-url 和 management.context-path两个属性值有关,如 managementUrl=http://127.0.0.1:8080/actuator,其中http://127.0.0.1:8080为management-base-url,/actuator是management.context-path
spring.boot.admin.client.instance.service-base-url 用于计算要注册的服务URL的基本URL。该路径是在运行时推断的,并附加到基本URL 默认该属性值与hostname, server.port有关,如http://127.0.0.1:8080,其中8080端口是配置的server.port。127.0.0.1是client所在服务器的hostname
spring.boot.admin.client.instance.service-url 要注册的服务网址。如果可访问的URL不同(例如Docker),则可以覆盖 默认值是基于service-base-url 和 server.context-path进行赋值
spring.boot.admin.client.instance.name 要注册的名称 默认值是配置的spring.application.name的值,如果没有配置该属性的话,默认值是spring-boot-application
spring.boot.admin.client.instance.prefer-ip 在猜测的网址中使用ip地址而不是主机名。如果设置了server.address/ management.address,它将被使用。否则,InetAddress.getLocalHost()将使用从返回的IP地址 false
spring.boot.admin.client.instance.metadata.* 要与此实例相关联的元数据键值对
spring.boot.admin.client.instance.metadata.tags.* 标记作为要与此实例相关联的键值对

示例代码

github

码云

文档参考

https://codecentric.github.io/spring-boot-admin/2.1.6/#faqs

非特殊说明,本文版权归 朝雾轻寒 所有,转载请注明出处.

原文标题:Spring Boot 2.X(十七):应用监控之 Spring Boot Admin 使用及配置

原文地址:https://www.zwqh.top/article/info/26

如果文章对您有帮助,请扫码关注下我的公众号,文章持续更新中...

Guess you like

Origin www.cnblogs.com/zwqh/p/11854760.html