spring-boot-starter-actuator 是什么
一句话,actuator是监控系统健康情况的工具。
- 怎么用?
1. 添加 POM依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2. 启动的时候就会有下面这些提示.
Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.uti
Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.ser
Mapped URL path [/webjars/**] onto handler of type [class org.springframework.we
Mapped URL path [/**] onto handler of type [class org.springframework.web.servle
Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframewor
Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto p
Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}"
Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" ont
Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application
Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/j
Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto
Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/json]}" onto
Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/json]
Mapped "{[/health || /health.json],produces=[application/json]}" onto public jav
Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" ont
Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/json]}" onto publi
Mapped "{[/env || /env.json],methods=[GET],produces=[application/json]}" onto pu
- actuator 的端点分为3类
- 应用配置类
/configprops /autoconfig /beans /env /info /mappings
- 度量指标类
/dump /health
- 操作控制类
-
下面找几个来解释
-
/autoconfig
-
自动化配置报告,可以看出一些自动化配置为什么没有生效
![](http://upload-images.jianshu.io/upload_images/9211971-02fd1309ccced1d9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/933/format/webp)
image.png
-
/beans
可以看到定义的所有的bean
![](http://upload-images.jianshu.io/upload_images/9211971-6c39a9695df30828.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/969/format/webp)
image.png
-
/configprops
可以看到application.properties里面的信息
![](http://upload-images.jianshu.io/upload_images/9211971-7b75c7b27e34cea9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/930/format/webp)
image.png
-
/env
![](http://upload-images.jianshu.io/upload_images/9211971-852d1f9105a166f7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/865/format/webp)
image.png
-
/mappings
![](http://upload-images.jianshu.io/upload_images/9211971-91db57ca42a730a2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/901/format/webp)
image.png
-
/info
返回application.properties文件中info开头的配置信息,如:
# /info端点信息配置
info.app.name=spring-boot-hello
info.app.version=v1.0.0
![](http://upload-images.jianshu.io/upload_images/9211971-c5644531cabf5726.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/848/format/webp)
image.png
下面是度量指标类
-
/metrics
![](http://upload-images.jianshu.io/upload_images/9211971-7802726678e69cc0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/765/format/webp)
image.png
我们也可以自定实现
CounterService
接口来实现count指标.![](http://upload-images.jianshu.io/upload_images/9211971-bbcb505a057208c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/516/format/webp)
image.png
也可以用 [/metrics/{name:.*}] 如: /metrics/mem.free 来获取单个指标信息
![](http://upload-images.jianshu.io/upload_images/9211971-3478e728717daeae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/657/format/webp)
image.png
-
/health
可以通过实现 HealthIndicator
接口来实现健康检查,返回值的状态信息在org.springframework.boot.actuate.health.Status
内
![](http://upload-images.jianshu.io/upload_images/9211971-843372a992e100ea.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/9211971-e253daa117f154bc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/387/format/webp)
image.png
-
/dump
调用 java.lang.management.ThreadMXBean
的
public ThreadInfo[] dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers);
方法来返回活动线程的信息
![](http://upload-images.jianshu.io/upload_images/9211971-8e9ba27da0ec84c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/457/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/9211971-8e046b9f2e7cd8b8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/769/format/webp)
image.png
-
操作控制类
如:/shutdown ,通过在application.properties文件中添加
endpoints.shutdown.enabled=true
来开启
![](http://upload-images.jianshu.io/upload_images/9211971-306dc38223319b4e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/647/format/webp)
image.png
</div>
</div>
Atitit nlp用到的技术与常见类库 目录 1. 常用的技术 1 1.1. 语言处理基础技术 分词 相似度等 1 1.2. 新闻摘要 2 1.3. 情感倾向分析 2 1.4. 文章标签 2 1.
Atitit 资源类型的分类法规范MIME类型类型 目录 1.1. 一个MIME类型至少包括两个部分:一个类型(type)和一个子类型(subtype)。 1 1.2. 命名格式MIME类型包括一个
Atitit 六种知识表示法 目录 1. 知识的静态描述和动态描述 1 1.状态空间表示 以状态和运算符(operator) 1 2.问题归约表示(函数式?? 1 (1)一个初始问题描述; 2 (2)
微信小程序登录流程总结 目录 1.1. 前端调用wx.login 。。给后端传递一个code 1 1.2. 开发者需要在开发者服务器后台调用 auth.code2Session,使用 code 换取
Atititi 计算机系 教材 目录 1. 硬件类 2 1.1. 《微机系统与接口技术》 2 1.2. 《计算机组成与系统结构(第2版)》 2 2. Atitit 操作系统原理 操作系统原理(cpu
Atitit 声音和音乐检索 多媒体信息检索 信息检索 目录 1.1. 14.4.5 音频基础知识 1 1.2. 多媒体信息检索的方法主要有哪些?其原理是什么? 1 1.3. 基于文本的检索和基于
Atitit 信息检索 v3 t55.docx Atitit 现代信息检索 目录 1.1. 信息检索(索引 索引 结构化文本 1 1.2. Atitit 重要章节 1 1.3. 息检索建模 1 1.
Atiitt 程序语言vm与rt 虚拟机与运行时 目录 1. 运行时 虚拟机的一种,一般指进程级别的虚拟机。 1 1.1. 线程模型 1 1.2. 堆栈机vs 寄存器 1 1.3. 存储模型 2 1
Atiitt 图像处理的常见功能业务用途与类库与功能实现 目录 1. 常见业务场景 3 1.1. 缩略图 蒙版遮罩挖空 3 1.2. 区域裁剪,水印,旋转 3 1.3. 判断图像大小分辨率要求