Integrated use of spring-boot-admin (single project)

Introduction

Spring Boot Admin provides a lot of service management functions. Using it can save us a lot of time and energy in managing services. Spring Boot Admin provides the following functions (including but not limited to):

Display health status and detailed information, such as JVM and memory indicators, data source indicators, cache indicators.
Track and download log files.
View JVM system and environment properties.
View Spring boot configuration properties.
Convenient loglevel management.
View thread dump.
View http-traces.
View http endpoint.
View scheduled tasks
View and delete active sessions (using spring-session)
status change notifications (via email, Slack, Hipchat...)
event logs of status changes (non-persistent)
...(and more!)

One, environment configuration

Because I am a single project server + client and put it together directly,

  • springboot 2.2.0 ,
  • spring-boot-admin 2.2.2 (Use boot corresponding to 2.2.0 should be better, just ignore it if there is no problem at present)

1. Maven dependency

  <!-- actuator 监控中心 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
       <!-- spring-boot-admin ,必须有 actuator监控中心 -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.2.2</version>
        </dependency>

2. yml-actuator monitoring, configure spring-boot-admin to use

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

3、yml - spring-boot-admin配置

spring:
  ## spring-boot-admin 配置
  boot:
    admin:
      ## admin 服务端访问地址
      context-path: /bootAdmin/
      ## admin 客户端连接服务端
      client:
        # 为了显示客户端的ip否则是以主机名显示的,这样需要添加hosts影射。
        instance:
          prefer-ip: true
        url: http://localhost:${server.port}/${spring.boot.admin.context-path}/
        #username: admin
        #password: admin@12345

4. yml-spring-boot-admin real-time log configuration

filePath is your own logback configuration, mainly logging.file, spring-boot-admin will automatically read the corresponding file

## logback日志输出
logging:
  # 日志目录, 线上请配置linux 绝对路径 如:/usr/local/work/xijia2/logs
  filePath: logs
  # 配置日志路径即可实时输出到 spring-boot-admin 日志管理
  file: src/main/resources/static/log/xijia.log

5. Add annotations to the startup class

@EnableAdminServer

2. Effect display

Homepage

Insert picture description here

system message

Insert picture description here

Environment configuration

Insert picture description here

Log

Insert picture description here

Deployment configuration, online real-time output files

logging.file = /usr/local/work/xijia2/log.txt

Insert picture description here

  • Personal open source project (universal background management system) –> https://gitee.com/wslxm/spring-boot-plus2 , you can check it out if you like

  • This is the end of this article. If you find it useful, please like or pay attention to it. We will continue to update more content from time to time... Thank you for watching!

Guess you like

Origin blog.csdn.net/qq_41463655/article/details/109152670