Spring Boot Actuator 和 Spring Boot Admin 集成环境与常见配置

精选30+云产品,助力企业轻松上云!>>> hot3.png

Spring Boot 应用集成 Spring Boot Actuator

Spring Boot Actuator 常规配置

maven依赖:

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

application.yml配置:

management:
  endpoint:
    health:
      show-details: always
      cache:
        time-to-live: 30s
    shutdown:
      enabled: true
    info:
      cache:
        time-to-live: 30s
  endpoints:
    web:
      exposure:
        include: "*"
      cors:
        allowed-origins: "*"
        allowed-methods: "*"

Spring Boot 应用集成 Spring Boot Admin Client

通过注册中心集成(被动集成)

maven依赖:

<dependency>-->
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

application.yml配置:

eureka:
  instance:
    hostname: ${spring.cloud.client.ip-address}
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ip-address}:${server.port}
  client:
    serviceUrl:
      defaultZone: @eureka.client.serviceUrl.defaultZone@
    register-with-eureka: false
主动集成

maven依赖:

<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-starter-client</artifactId>
	<version>${spring-boot-admin.version}</version>
</dependency>

application.yml配置:

spring:
  boot:
    admin:
      client:
        url: @spring.boot.admin.client.url@
        instance:
          prefer-ip: true

Spring Boot Admin Server(服务端)

常规配置

maven依赖:

<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>

application.yml配置:

server:
  port: @server.port@

spring:
  application:
    name: spring-boot-admin-server
  profiles:
    active: @spring.profiles.active@
  security:
    user:
      name: @spring.security.user.name@
      password: @spring.security.user.password@
  mail:
    host: smtp.exmail.qq.com
    port: 465
    username: devops@xxx.com
    password: ENC(n6KG9CBMqfqhaEf8tXYA99T0LPF6VDJr)
    protocol: smtp
    test-connection: true
    default-encoding: UTF-8
    properties:
      mail.smtp.auth: true
      mail.smtp.starttls.enable: true
      mail.smtp.starttls.required: true
      mail.smtp.ssl.enable: true
      mail.display.sendmail: spring-boot-admin-server(xxx监控平台)
  boot:
    admin:
      notify:
        mail:
          from: devops@xxx.com
          to: wn@xxx.com,zjs@xxx.com,zyl@xxx.com
          enabled: true
      monitor:
        period: 60000ms
        status-lifetime: 60000ms

jasypt:
  encryptor:
    password: spring-boot-admin-server

eureka:
  instance:
    hostname: ${spring.cloud.client.ip-address}
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ip-address}:${server.port}
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /actuator/health
    metadata-map:
      #startup: ${random.int}    #needed to trigger info and endpoint update after restart
      user.name: ${spring.security.user.name}
      user.password: ${spring.security.user.password}
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: @eureka.client.serviceUrl.defaultZone@
    register-with-eureka: false

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


参考资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值