Springboot学习笔记之应用监控actuator
Springboot学习笔记之应用监控actuator
前言
Actuator监控管理
pom 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
端点介绍
/actuator 所有 Endpoint 的列表
访问 http://IP:PORT/actuator/** 即可查询下面端点
ID | Description | Enabled by default |
---|---|---|
auditevents |
Exposes audit events information for the current application. | Yes |
beans |
Displays a complete list of all the Spring beans in your application. | Yes |
caches |
Exposes available caches. | Yes |
conditions |
Shows the conditions that were evaluated on configuration and auto-configuration classes and the reasons why they did or did not match. | Yes |
configprops |
Displays a collated list of all @ConfigurationProperties . |
Yes |
env |
Exposes properties from Spring’s ConfigurableEnvironment . |
Yes |
flyway |
Shows any Flyway database migrations that have been applied. | Yes |
health |
Shows application health information. | Yes |
httptrace |
Displays HTTP trace information (by default, the last 100 HTTP request-response exchanges). | Yes |
info |
Displays arbitrary application info. | Yes |
integrationgraph |
Shows the Spring Integration graph. | Yes |
loggers |
Shows and modifies the configuration of loggers in the application. | Yes |
liquibase |
Shows any Liquibase database migrations that have been applied. | Yes |
metrics |
Shows ‘metrics’ information for the current application. | Yes |
mappings |
Displays a collated list of all @RequestMapping paths. |
Yes |
scheduledtasks |
Displays the scheduled tasks in your application. | Yes |
sessions |
Allows retrieval and deletion of user sessions from a Spring Session-backed session store. Not available when using Spring Session’s support for reactive web applications. | Yes |
shutdown |
Lets the application be gracefully shutdown. | No |
threaddump |
Performs a thread dump. | Yes |
shutdown 端点默认关闭可以通过下面设置开启
management:
endpoint:
shutdown:
# 开启端点关闭
enabled: true
shutdown 端口只支持 post 请求
定制端点
定制端点路径
management:
endpoints:
web:
base-path: /myEndpoints
访问 shutdown 端点:http://localhost:8001/myEndpoints/shutdown
定制端口
management:
server:
port: 8008
访问 shutdown 端点:http://localhost:8008/actuator/shutdown
关闭部分端点
management:
endpoints:
web:
exposure:
# 暴露所有监控端点
include: "*"
# 关闭配置的端点
exclude: info, health
开启部分端点
# 监控端点默认关闭,只需要在 include 配置即可
management:
endpoints:
web:
exposure:
# 暴露以下监控端点
include: health,info
Jconsole 监控管理
在控制台中调用java内置的 jconsole 来实现 JMX 监控
打开 jconsole 页面,选择本地进程或者远程进程都可