Spring Cloud Admin

发布时间 2023-10-07 21:19:48作者: -Lucas

一、Admin简介

提供友好的界面展示actuator统计的数据,可以很好的监控整个微服务系统中的实例运行情况信息。
服务异常告警。

二、服务端配置

启动类添加@EnableAdminServer注解

<!-- Admin 服务 -->
<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<!-- Admin 界面 -->
<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency>

三、微服务段配置

<!-- Admin 服务 -->
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>2.2.1</version>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
spring:
  boot:
    admin:
      client:
        url: http://localhost:8101
management:
  #开启所有端点
  endpoints:
    web:
      exposure:
        include: '*'
  # 开启shutdown端口 调用关闭服务
  endpoint:
    shutdown:
      enabled: true
    # 切换hystrix 线程隔离方式变更为信号量模式
    health:
      show-details: always

四、邮件通知配置

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
spring:
  mail:
    host: smtp.qq.com
    username: 123456
    password: XXXXXX
    properties:
      mail:
        smpt:
          auth: true
          starttls:
            enable: true
            required: true
  boot:
    admin:
      notify:
        mail:
          #收件邮箱
          to: 123456@qq.com
          # 发件邮箱  必须和上边username账号配置一样
          from: 123456@qq.com