Spring Boot Admin - 监控部署 - 邮件监控报警

        目前项目中用到了最基本的两个监控:spring boot admin和spring cloud hystrix,这里先介绍一下spring boot admin的实战。

添加依赖

  1. spring cloud
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    
    <properties>
        <java.version>1.8</java.version>
        <spring.cloud.version>Edgware.RELEASE</spring.cloud.version>
        <spring.boot.admin.version>1.5.7</spring.boot.admin.version>
        <profiles.dir>src/main/profiles</profiles.dir>
    </properties>
    
    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring.cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

     

配置文件

server:
    port: 8083

spring:
  application:
    name: monitor-admin
  jackson:
    serialization:
      indent_output: true
  mail:
    host: mx1.qq.com
  boot:
    admin:
      notify:
        mail:
          to: yourEmail@qq.com
  output:
    ansi:
      enabled: always

endpoints:
  health:
    sensitive: false

eureka:
  client:
    serviceUrl:
      defaultZone: http://eureka1:1111//eureka/
  instance:
    prefer-ip-address: true
    leaseExpirationDurationInSeconds: 30
    leaseRenewalIntervalInSeconds: 10

management:
  security:
    enabled: false
  endpoints:
    web:
      exposure:
        include: "*"  #<2>

endpoint:
  health:
    show-details: ALWAYS

这里有几个注意点:

  1. 邮件报警
    ●检测服务器的基本运行状态,宕机通知
    ●spring.boot.admin.notify.mail.to=yourEmail@qq.com
    ●具体的配置信息参照:http://codecentric.github.io/spring-boot-admin/1.5.7/#mail-notifications
    ●默认效果图:
    181228_w1UT_226613.png181335_sWnt_226613.png
  2. endpoints.health.sensitive
    设置为false,将所有的健康信息都暴漏显示。
  3. management.security.enabled
    设置为false,关闭安全限制
    与上个参数结合使用效果如下:
    181827_CFMd_226613.png
  4. endpoint.health.show-details
    182310_Zp2H_226613.png
    参考:http://mip.breakyizhan.com/springboot/3436.html

效果图

182357_4GNg_226613.png

  1. 如果被监控的服务器,没有关闭安全限制,点击“Details”,只能看到部分信息,效果如下图:
    182502_3LSq_226613.png
  2. 如果想要看到更多的信息,需要设置management.security.enabled为false,设置后效果如下图:
    182907_cnzy_226613.png

转载于:https://my.oschina.net/xiaowangqiongyou/blog/1647236

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值