spring boot 运行时监控actuator


git地址
https://github.com/a18792721831/studySpringCloud.git

1. 如何引入actuator

新建一个spring web项目,然后,在gradle依赖中增加

	implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-configuration-processor'
    providedCompile 'org.projectlombok:lombok'

等gradle加载完依赖构建后,启动:
在这里插入图片描述
然后访问http://localhost:8080/acruator/
将会得到
在这里插入图片描述
接着访问http://localhost:8080/actuator/health
得到
在这里插入图片描述

2. 加载详细信息

在application.yml中增加
在这里插入图片描述
启动
重新访问http://localhost:8080/actuator/health
在这里插入图片描述

3. actuator api介绍

Actuator提供了13个api接口,用于监控运行状态的spring boot的状况。
首先在application.yml配置文件中将所有的api全部暴露
在这里插入图片描述
在这里插入图片描述

类型 API接口 描述 示例
GET /configprops 描述配置属性如何注入Bean 在这里插入图片描述
GET /beans 描述ing用程序上下文里全部的Beanm以及他们的关系 在这里插入图片描述
GET /heapdump 获取快照 在这里插入图片描述
GET /threaddump 获取线程活动的快照 在这里插入图片描述
GET /env 获取全部环境属性 在这里插入图片描述
GET /env/{name} 根据名称获取特定的环境属性 在这里插入图片描述
GET /health 应用程序的健康指标 在这里插入图片描述
GET /info 获取应用程序的信息 在这里插入图片描述
GET /mappings 描述全部的url以及控制器 在这里插入图片描述
GET /metrics 获取应用程序的全部度量信息 在这里插入图片描述
GET /metrics/{name} 获取程序的指定名称的度量信息 在这里插入图片描述
GET /shutdown 关闭应用程序 需要将endpoints.shutown.enabled设置为true
发布了182 篇原创文章 · 获赞 88 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/a18792721831/article/details/104363642