springBoot actuator监控配置及使用

关注公众号:程序猿王国         持续更新,每日分享

准备环境:

  一个springBoot工程

第一步:添加以下依赖

  <dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-actuator</artifactId>

  </dependency>

第二步:在properties文件中配置actuator权限配置(否则访问一些暴露的监控信息会报401,很多博客里没有这一项,让很多人误解了

  management.security.enabled=false

简单介绍:

ID描述敏感(Sensitive)
autoconfig 显示一个auto-configuration的报告,该报告展示所有auto-configuration候选者及它们被应用或未被应用的原因 true
beans 显示一个应用中所有Spring Beans的完整列表 true
configprops 显示一个所有@ConfigurationProperties的整理列表 true
dump 执行一个线程转储 true
env 暴露来自Spring ConfigurableEnvironment的属性 true
health 展示应用的健康信息(当使用一个未认证连接访问时显示一个简单的’status’,使用认证连接访问则显示全部信息详情) false
info 显示任意的应用信息 false
metrics 展示当前应用的’指标’信息 true
mappings 显示一个所有@RequestMapping路径的整理列表 true
shutdown 允许应用以优雅的方式关闭(默认情况下不启用) true
trace 显示trace信息(默认为最新的一些HTTP请求) true

 

接下来实际操作一下吧(简单举个栗子):

  beans(显示一个应用中所有Spring Beans的完整列表)

  启动springBoot应用后,浏览器访问localhost:8080/项目名/beans,浏览器就会显示Bean列表

  health

  首先需配置

    endpoints.health.sensitive=false

  浏览器访问localhost:8080/项目名/health,浏览器就会显示健康信息

剩下的我就不一一列出来了,希望能帮到各位

原文地址:https://www.cnblogs.com/gslblog/p/7150626.html