1.引入相关依赖 actuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2.添加相关配置
# 属性列出了公开的端点的ID
management.endpoints.web.exposure.include=*
3.浏览器地址栏输入 :http://127.0.0.1/actuator/ 返回以下结果
在使用Http访问端点时,需要加上默认/actuator 前缀
{
links: {
self: {
href: "http://127.0.0.1/actuator",
templated: false,
},
auditevents: {
href: "http://127.0.0.1/actuator/auditevents",
templated: false,
},
beans: {
href: "http://127.0.0.1/actuator/beans",
templated: false,
},
caches - cache: {
href: "http://127.0.0.1/actuator/caches/{cache}",
templated: true,
},
caches: {
href: "http://127.0.0.1/actuator/caches",
templated: false,
},
health - component - instance: {
href: "http://127.0.0.1/actuator/health/{component}/{instance}",
templated: true,
},
health - component: {
href: "http://127.0.0.1/actuator/health/{component}",
templated: true,
},
health: {
href: "http://127.0.0.1/actuator/health",
templated: false,
},
conditions: {
href: "http://127.0.0.1/actuator/conditions",
templated: false,
},
configprops: {
href: "http://127.0.0.1/actuator/configprops",
templated: false,
},
env: {
href: "http://127.0.0.1/actuator/env",
templated: false,
},
env - toMatch: {
href: "http://127.0.0.1/actuator/env/{toMatch}",
templated: true,
},
info: {
href: "http://127.0.0.1/actuator/info",
templated: false,
},
loggers: {
href: "http://127.0.0.1/actuator/loggers",
templated: false,
},
loggers - name: {
href: "http://127.0.0.1/actuator/loggers/{name}",
templated: true,
},
heapdump: {
href: "http://127.0.0.1/actuator/heapdump",
templated: false,
},
threaddump: {
href: "http://127.0.0.1/actuator/threaddump",
templated: false,
},
metrics: {
href: "http://127.0.0.1/actuator/metrics",
templated: false,
},
metrics - requiredMetricName: {
href: "http://127.0.0.1/actuator/metrics/{requiredMetricName}",
templated: true,
},
scheduledtasks: {
href: "http://127.0.0.1/actuator/scheduledtasks",
templated: false,
},
httptrace: {
href: "http://127.0.0.1/actuator/httptrace",
templated: false,
},
mappings: {
href: "http://127.0.0.1/actuator/mappings",
templated: false,
},
}
}
4. 请求解释:
HTTP方法 | 路径 | 描述 | 是否敏感信息 |
GET | /actuator/auditevents | 显示当前审计信息 | true |
GET | /actuator/configprops | 查看配置属性,包括默认配置, 显示一个所有@ConfigurationProperties的整理列表 | true |
GET | /actuator/beans | bean及其关系列表, 显示一个应用中所有Spring Beans的完整列表 | true |
GET | /actuator/heapdump | 堆信息 | true |
GET | /actuator/env | 查看所有环境变量 | true |
GET | /actuator/env/{name} | 查看具体变量值 | true |
GET | /actuator/health | 查看应用健康指标, 当使用一个未认证连接访问时显示一个简单的’status’,使用认证连接访问则显示全部信息详情 | false |
GET | /actuator/info | 查看应用信息 | false |
GET | /actuator/mappings | 查看所有url映射, 即所有@RequestMapping路径的整理列表 | true |
GET | /actuator/metrics | 查看应用基本指标 | true |
GET | /actuator/metrics/{name} | 查看具体指标 | true |
POST | /actuator/shutdown | 关闭应用,允许应用以优雅的方式关闭(默认情况下不启用) | true |
GET | /actuator/httptrace | 查看基本追踪信息,默认为最新的一些HTTP请求 | true |
GET | /actuator/scheduledtasks | 定时任务信息 | false |
GET | /actuator/threaddump | 执行一个线程dump | true |
5. shutdown 默认关闭 ,添加一下配置 开启shutdown,且只支持post请求
management.endpoint.shutdown.enabled=true