首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SpringBoot admin 2.1 详解

SpringBoot admin 2.1 详解

作者头像
似水的流年
发布2020-02-14 15:08:09
1.5K0
发布2020-02-14 15:08:09
举报
文章被收录于专栏:电光石火电光石火

Spring Boot Admin是一个开源社区项目,用于管理和监控SpringBoot应用程序。 应用程序作为Spring Boot Admin Client向为Spring Boot Admin Server注册(通过HTTP)或使用SpringCloud注册中心(例如Eureka,Consul)发现。 UI是的Vue.js应用程序,展示Spring Boot Admin Client的Actuator端点上的一些监控。服务端采用Spring WebFlux + Netty的方式。Spring Boot Admin为注册的应用程序提供以下功能:

  • 显示健康状况
  • 显示详细信息,例如
  • JVM和内存指标
  • micrometer.io指标
  • 数据源指标
  • 缓存指标
  • 显示构建信息编号
  • 关注并下载日志文件
  • 查看jvm system-和environment-properties
  • 查看Spring Boot配置属性
  • 支持Spring Cloud的postable / env-和/ refresh-endpoint
  • 轻松的日志级管理
  • 与JMX-beans交互
  • 查看线程转储
  • 查看http-traces
  • 查看auditevents
  • 查看http-endpoints
  • 查看计划任务
  • 查看和删除活动会话(使用spring-session)
  • 查看Flyway / Liquibase数据库迁移
  • 下载heapdump
  • 状态变更通知(通过电子邮件,Slack,Hipchat,......)
  • 状态更改的事件日志(非持久性)

一、在bulid.gradle中添加

dependencies {
  compile group: 'de.codecentric', name: 'spring-boot-admin-starter-server', version: '2.1.6'

  compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail'

  compile group: 'com.alibaba.cloud', name: 'spring-cloud-starter-alibaba-nacos-discovery'

  // 安全配置
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-security'
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
}

二、bootstrap.yml中

server:
  port: 8391
  tomcat:
    max-threads: 500 # Maximum amount of worker threads.
  min-spare-threads: 50 # Minimum amount of worker threads

pigframe:
  nacos:
    server-addr: 127.0.0.1:8848
    namespace: 701cead9-85b6-4818-b411-130eef6d4240

spring:
  application:
    name: monitor
  main:
    allow-bean-definition-overriding: true
 security:
    user:
      name: admin #SpringBootAdmin登录时的用户名
  password: pigframe #SpringBootAdmin登录时的密码
  cloud:
    nacos:
      discovery:
        server-addr: ${pigframe.nacos.server-addr}
        namespace: ${pigframe.nacos.namespace}
        metadata:
          user.name: ${spring.security.user.name}
          user.password: ${spring.security.user.password}
  boot:
    admin:
      notify:
        mail:
          enabled: true
          to: 250502876@qq.com
          from: xxx@163.com
          # ignore-changes: UNKNOWN:UP
          ignore-changes:
            - "*:UP" #从任何状态到up状态都不要发邮件通知
      ui:
        title: 小猪快速开发框架监控
      turbine:
        clusters: default
        #,unieap-eureka-server-single
        location: monitor #turbine
      routes:
        endpoints: env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream,turbine.stream,activiti
      monitor:
        # 超时时间(单位:ms)
        read-timeout: 20000
  mail:
    host: smtp.163.com
    port: 465
    protocol: smtp
    test-connection: false
    default-encoding: UTF-8
    username: xxx@163.com
    password: 123456
    properties:
      mail:
        imap:
          ssl:
            socketFactory:
              fallback: false
        smtp:
          ssl:
            enable: true
            socketFactory:
              class: com.fintech.modules.util.MailSSLSocketFactory
          auth : true
          timeout : 2000
          starttls:
            enable : true
            required : true

turbine:
  app-config: gateway #收集监控信息的服务名
  combine-host-port: true
  cluster-name-expression: new String('default') #集群名称

#设置最大超时时间
ribbon:
  eager-load:
    enabled: true
 ServerListRefreshInterval: 10  #刷新服务列表源的间隔时间
  OkToRetryOnAllOperations: true
  MaxAutoRetries: 1
  MaxAutoRetriesNextServer: 1
  ReadTimeout: 16000
  ConnectTimeout: 16000

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

三、启动类

@EnableAdminServer
@EnableDiscoveryClient
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class MonitorApplication {
    public static void main(String[] args) {
        SpringApplication.run(MonitorApplication.class, args);
        System.out.println("==================MonitorApplication Start============");
    }
}

四、注册到注册中心的客户端

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

五、如果是不注册到注册中的客户端平配置

compile group: 'de.codecentric', name: 'spring-boot-admin-starter-client'
  • spring.boot.admin.client.url:要注册的Spring Boot Admin Server的URL。
  • management.endpoints.web.exposure.include:与Spring Boot 2一样,默认情况下,大多数actuator的端口都不会通过http公开,* 代表公开所有这些端点。对于生产环境,应该仔细选择要公开的端点。
spring:
  application:
    name: admin-client
  boot:
    admin:
      client:
        url: http://localhost:8391
server:
  port: 8768

management:
  endpoints:
    web:
      exposure:
        include: '*'
  endpoint:
    health:
      show-details: ALWAYS
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-01-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
微服务引擎 TSE
微服务引擎(Tencent Cloud Service Engine)提供开箱即用的云上全场景微服务解决方案。支持开源增强的云原生注册配置中心(Zookeeper、Nacos 和 Apollo),北极星网格(腾讯自研并开源的 PolarisMesh)、云原生 API 网关(Kong)以及微服务应用托管的弹性微服务平台。微服务引擎完全兼容开源版本的使用方式,在功能、可用性和可运维性等多个方面进行增强。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档