# Actuator
应用监控
# 开启监控
配置依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
1
2
3
4
# 默认端点
Spring Boot 2.0 的Actuator只暴露了health和info端点,提供的监控信息无法满足我们的需求
在1.x中有n多可供我们监控的节点,官方的回答是为了安全….
# 开启所有端点
在application.yml中加入如下配置信息
#开启所有端点 *代表所有节点都加载
management.endpoints.web.exposure.include=*
1
2
3
2
3
所有端点都开启后的api列表
{
"_links": {
"self": {
"href": "http://localhost/actuator",
"templated": false
},
"archaius": {
"href": "http://localhost/actuator/archaius",
"templated": false
},
"beans": {
"href": "http://localhost/actuator/beans",
"templated": false
},
"caches-cache": {
"href": "http://localhost/actuator/caches/{cache}",
"templated": true
},
"caches": {
"href": "http://localhost/actuator/caches",
"templated": false
},
"health": {
"href": "http://localhost/actuator/health",
"templated": false
},
"health-path": {
"href": "http://localhost/actuator/health/{*path}",
"templated": true
},
"info": {
"href": "http://localhost/actuator/info",
"templated": false
},
"conditions": {
"href": "http://localhost/actuator/conditions",
"templated": false
},
"configprops": {
"href": "http://localhost/actuator/configprops",
"templated": false
},
"env": {
"href": "http://localhost/actuator/env",
"templated": false
},
"env-toMatch": {
"href": "http://localhost/actuator/env/{toMatch}",
"templated": true
},
"loggers-name": {
"href": "http://localhost/actuator/loggers/{name}",
"templated": true
},
"loggers": {
"href": "http://localhost/actuator/loggers",
"templated": false
},
"heapdump": {
"href": "http://localhost/actuator/heapdump",
"templated": false
},
"threaddump": {
"href": "http://localhost/actuator/threaddump",
"templated": false
},
"metrics-requiredMetricName": {
"href": "http://localhost/actuator/metrics/{requiredMetricName}",
"templated": true
},
"metrics": {
"href": "http://localhost/actuator/metrics",
"templated": false
},
"scheduledtasks": {
"href": "http://localhost/actuator/scheduledtasks",
"templated": false
},
"mappings": {
"href": "http://localhost/actuator/mappings",
"templated": false
},
"refresh": {
"href": "http://localhost/actuator/refresh",
"templated": false
},
"features": {
"href": "http://localhost/actuator/features",
"templated": false
},
"service-registry": {
"href": "http://localhost/actuator/service-registry",
"templated": false
},
"jolokia": {
"href": "http://localhost/actuator/jolokia",
"templated": false
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# api端点功能
# Health
显示系统状态
{"status":"UP"}
# shutdown
用来关闭节点
- 开启远程关闭功能
management.endpoint.shutdown.enabled=true
1
- 使用Post方式请求端点
{
"message": "Shutting down, bye..."
}
1
2
3
2
3
# autoconfig
获取应用的自动化配置报告 beans
获取应用上下文中创建的所有Bean
# configprops
获取应用中配置的属性信息报告
# env
获取应用所有可用的环境属性报告
# Mappings
获取应用所有Spring Web的控制器映射关系报告
# info
获取应用自定义的信息
# metrics
返回应用的各类重要度量指标信息
Metrics节点并没有返回全量信息,我们可以通过不同的key去加载我们想要的值
metrics/jvm.memory.max
# Threaddump
1.x中为dump
返回程序运行中的线程信息