我们都知道Spring Boot是一个用于快速开发Java Web的框架,不需要太多的配置即可使用Spring的大量功能。Spring Boot遵循着“约定大于配置”的原则,许多功能使用默认的配置即可。这样的做法好处在于我们不需要像使用Spring那样编写一大堆的XML配置代码,但过于简单的配置过程会让我们在了解各种依赖,配置之间的关系过程上带来一些困难。不过没关系,在Spring Boot中,我们可以使用Actuator来监控应用,Actuator提供了一系列的RESTful API让我们可以更为细致的了解各种信息。

引入Actuator

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-actuator</artifactId>
  4. </dependency>

配置Actuator

  1. server:
  2. port: 80
  3. management:
  4. security:
  5. enabled: false #关掉安全认证
  6. port: 80
  7. context-path: /monitor #actuator的访问路径
  8. endpoints:
  9. shutdown:
  10. enabled: true

配置中关闭了安全认证的功能,如果需要开启这个功能的话还需引入spring-boot-starter-security依赖。除了使用Spring Security来开启监控路径安全认证外,还可以使用Shiro对监控路径进行权限控制。

监控的端口和应用一致,配置context-path/monitor,这样可以避免和自己应用的路径映射地址重复。

endpoints.shutdown.enabled: true提供了使用post请求来关闭Spring Boot应用的功能。

Actuator接口列表

Actuator提供了13个接口,可以分为三大类:配置接口、度量接口和其它接口,具体如下表所示:

HTTP 方法 路径 描述
GET /autoconfig 提供了一份自动配置报告,记录哪些自动配置条件通过了,哪些没通过
GET /configprops 描述配置属性(包含默认值)如何注入Bean
GET /beans 描述应用程序上下文里全部的Bean,以及它们的关系
GET /dump 获取线程活动的快照
GET /env 获取全部环境属性
GET /env/{name} 根据名称获取特定的环境属性值
GET /health 报告应用程序的健康指标,这些值由HealthIndicator的实现类提供
GET /info 获取应用程序的定制信息,这些信息由info打头的属性提供
GET /mappings 描述全部的URI路径,以及它们和控制器(包含Actuator端点)的映射关系
GET /metrics 报告各种应用程序度量信息,比如内存用量和HTTP请求计数
GET /metrics/{name} 报告指定名称的应用程序度量值
POST /shutdown 关闭应用程序,要求endpoints.shutdown.enabled设置为true
GET /trace 提供基本的HTTP请求跟踪信息(时间戳、HTTP头等)

接口使用示例

autoconfig

显示所有自动装配类的报告,以及是什么原因导致自动装配成功或者不成功。在浏览器输入:http://localhost/monitor/autoconfig,输出如下(截取部分):

  1. {
  2. "positiveMatches": {
  3. "AuditAutoConfiguration#auditListener": [{
  4. "condition": "OnBeanCondition",
  5. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.audit.listener.AbstractAuditListener; SearchStrategy: all) did not find any beans"
  6. }],
  7. "AuditAutoConfiguration.AuditEventRepositoryConfiguration": [{
  8. "condition": "OnBeanCondition",
  9. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.audit.AuditEventRepository; SearchStrategy: all) did not find any beans"
  10. }],
  11. "EndpointAutoConfiguration#autoConfigurationReportEndpoint": [{
  12. "condition": "OnBeanCondition",
  13. "message": "@ConditionalOnBean (types: org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; SearchStrategy: all) found bean 'autoConfigurationReport'; @ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint; SearchStrategy: current) did not find any beans"
  14. }],
  15. "EndpointAutoConfiguration#beansEndpoint": [{
  16. "condition": "OnBeanCondition",
  17. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.BeansEndpoint; SearchStrategy: all) did not find any beans"
  18. }],
  19. "EndpointAutoConfiguration#configurationPropertiesReportEndpoint": [{
  20. "condition": "OnBeanCondition",
  21. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.ConfigurationPropertiesReportEndpoint; SearchStrategy: all) did not find any beans"
  22. }],
  23. "EndpointAutoConfiguration#dumpEndpoint": [{
  24. "condition": "OnBeanCondition",
  25. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.DumpEndpoint; SearchStrategy: all) did not find any beans"
  26. }],
  27. "EndpointAutoConfiguration#environmentEndpoint": [{
  28. "condition": "OnBeanCondition",
  29. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.EnvironmentEndpoint; SearchStrategy: all) did not find any beans"
  30. }],
  31. "EndpointAutoConfiguration#healthEndpoint": [{
  32. "condition": "OnBeanCondition",
  33. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.HealthEndpoint; SearchStrategy: all) did not find any beans"
  34. }],
  35. "EndpointAutoConfiguration#infoEndpoint": [{
  36. "condition": "OnBeanCondition",
  37. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.InfoEndpoint; SearchStrategy: all) did not find any beans"
  38. }],
  39. "EndpointAutoConfiguration#loggersEndpoint": [{
  40. "condition": "OnBeanCondition",
  41. "message": "@ConditionalOnBean (types: org.springframework.boot.logging.LoggingSystem; SearchStrategy: all) found bean 'springBootLoggingSystem'; @ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.LoggersEndpoint; SearchStrategy: all) did not find any beans"
  42. }],
  43. "EndpointAutoConfiguration#metricsEndpoint": [{
  44. "condition": "OnBeanCondition",
  45. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.MetricsEndpoint; SearchStrategy: all) did not find any beans"
  46. }],
  47. "EndpointAutoConfiguration#shutdownEndpoint": [{
  48. "condition": "OnBeanCondition",
  49. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.ShutdownEndpoint; SearchStrategy: all) did not find any beans"
  50. }],
  51. "EndpointAutoConfiguration#traceEndpoint": [{
  52. "condition": "OnBeanCondition",
  53. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.TraceEndpoint; SearchStrategy: all) did not find any beans"
  54. }],
  55. "EndpointAutoConfiguration.RequestMappingEndpointConfiguration": [{
  56. "condition": "OnClassCondition",
  57. "message": "@ConditionalOnClass found required class 'org.springframework.web.servlet.handler.AbstractHandlerMethodMapping'; @ConditionalOnMissingClass did not find unwanted class"
  58. }],
  59. "EndpointAutoConfiguration.RequestMappingEndpointConfiguration#requestMappingEndpoint": [{
  60. "condition": "OnBeanCondition",
  61. "message": "@ConditionalOnMissingBean (types: org.springframework.boot.actuate.endpoint.RequestMappingEndpoint; SearchStrategy: all) did not find any beans"
  62. }],
  63. ...
  64. }

beans

查看Spring 容器管理的Bean,访问http://localhost/monitor/beans,输出如下(截取部分):

  1. [{
  2. "context": "application:80",
  3. "parent": null,
  4. "beans": [{
  5. "bean": "demoApplication",
  6. "aliases": [],
  7. "scope": "singleton",
  8. "type": "com.springboot.demo.DemoApplication$$EnhancerBySpringCGLIB$$77e6b2b4",
  9. "resource": "null",
  10. "dependencies": []
  11. }, {
  12. "bean": "org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory",
  13. "aliases": [],
  14. "scope": "singleton",
  15. "type": "org.springframework.core.type.classreading.CachingMetadataReaderFactory",
  16. "resource": "null",
  17. "dependencies": []
  18. }, {
  19. "bean": "org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration",
  20. "aliases": [],
  21. "scope": "singleton",
  22. "type": "org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration$$EnhancerBySpringCGLIB$$dc9af024",
  23. "resource": "null",
  24. "dependencies": []
  25. }, {
  26. "bean": "org.springframework.boot.autoconfigure.condition.BeanTypeRegistry",
  27. "aliases": [],
  28. "scope": "singleton",
  29. "type": "org.springframework.boot.autoconfigure.condition.BeanTypeRegistry",
  30. "resource": "null",
  31. "dependencies": []
  32. }, {
  33. "bean": "propertySourcesPlaceholderConfigurer",
  34. "aliases": [],
  35. "scope": "singleton",
  36. "type": "org.springframework.context.support.PropertySourcesPlaceholderConfigurer",
  37. "resource": "class path resource [org/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.class]",
  38. "dependencies": []
  39. }, {
  40. "bean": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration",
  41. "aliases": [],
  42. "scope": "singleton",
  43. "type": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$$EnhancerBySpringCGLIB$$a4dba584",
  44. "resource": "null",
  45. "dependencies": []
  46. }, {
  47. "bean": "standardJacksonObjectMapperBuilderCustomizer",
  48. "aliases": [],
  49. "scope": "singleton",
  50. "type": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$StandardJackson2ObjectMapperBuilderCustomizer",
  51. "resource": "class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration.class]",
  52. "dependencies": ["org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@78f30883", "spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties"]
  53. }, {
  54. "bean": "spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties",
  55. "aliases": [],
  56. "scope": "singleton",
  57. "type": "org.springframework.boot.autoconfigure.jackson.JacksonProperties",
  58. "resource": "null",
  59. "dependencies": []
  60. }, {
  61. "bean": "org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor",
  62. "aliases": [],
  63. "scope": "singleton",
  64. "type": "org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor",
  65. "resource": "null",
  66. "dependencies": ["org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store"]
  67. }, {
  68. "bean": "org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store",
  69. "aliases": [],
  70. "scope": "singleton",
  71. "type": "org.springframework.boot.context.properties.ConfigurationBeanFactoryMetaData",
  72. "resource": "null",
  73. "dependencies": []
  74. }, {
  75. "bean": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration",
  76. "aliases": [],
  77. "scope": "singleton",
  78. "type": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration$$EnhancerBySpringCGLIB$$e9c4bf95",
  79. "resource": "null",
  80. "dependencies": ["org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@78f30883"]
  81. }, {
  82. "bean": "jacksonObjectMapperBuilder",
  83. "aliases": [],
  84. "scope": "singleton",
  85. "type": "org.springframework.http.converter.json.Jackson2ObjectMapperBuilder",
  86. "resource": "class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration.class]",
  87. "dependencies": ["standardJacksonObjectMapperBuilderCustomizer"]
  88. }, {
  89. "bean": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration",
  90. "aliases": [],
  91. "scope": "singleton",
  92. "type": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration$$EnhancerBySpringCGLIB$$3777fd7c",
  93. "resource": "null",
  94. "dependencies": []
  95. }, {
  96. "bean": "jacksonObjectMapper",
  97. "aliases": [],
  98. "scope": "singleton",
  99. "type": "com.fasterxml.jackson.databind.ObjectMapper",
  100. "resource": "class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperConfiguration.class]",
  101. "dependencies": ["jacksonObjectMapperBuilder"]
  102. }, {
  103. "bean": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration",
  104. "aliases": [],
  105. "scope": "singleton",
  106. "type": "org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$$EnhancerBySpringCGLIB$$19839b0b",
  107. "resource": "null",
  108. "dependencies": []
  109. }, {
  110. "bean": "jsonComponentModule",
  111. "aliases": [],
  112. "scope": "singleton",
  113. "type": "org.springframework.boot.jackson.JsonComponentModule",
  114. "resource": "class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.class]",
  115. "dependencies": []
  116. }, {
  117. "bean": "org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$TomcatWebSocketConfiguration",
  118. "aliases": [],
  119. "scope": "singleton",
  120. "type": "org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$TomcatWebSocketConfiguration$$EnhancerBySpringCGLIB$$ab6fe14",
  121. "resource": "null",
  122. "dependencies": []
  123. }, {
  124. "bean": "websocketContainerCustomizer",
  125. "aliases": [],
  126. "scope": "singleton",
  127. "type": "org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer",
  128. "resource": "class path resource [org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration$TomcatWebSocketConfiguration.class]",
  129. "dependencies": []
  130. }, {
  131. "bean": "org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration",
  132. "aliases": [],
  133. "scope": "singleton",
  134. "type": "org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$$EnhancerBySpringCGLIB$$ee951243",
  135. "resource": "null",
  136. "dependencies": []
  137. }, {
  138. "bean": "org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat",
  139. "aliases": [],
  140. "scope": "singleton",
  141. "type": "org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat$$EnhancerBySpringCGLIB$$8f67c107",
  142. "resource": "null",
  143. "dependencies": []
  144. }, {
  145. "bean": "tomcatEmbeddedServletContainerFactory",
  146. "aliases": [],
  147. "scope": "singleton",
  148. "type": "org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory",
  149. "resource": "class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]",
  150. "dependencies": []
  151. }, {
  152. "bean": "org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration",
  153. "aliases": [],
  154. "scope": "singleton",
  155. "type": "org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$$EnhancerBySpringCGLIB$$48514e2b",
  156. "resource": "null",
  157. "dependencies": []
  158. }, {
  159. "bean": "embeddedServletContainerCustomizerBeanPostProcessor",
  160. "aliases": [],
  161. "scope": "singleton",
  162. "type": "org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor",
  163. "resource": "null",
  164. "dependencies": []
  165. }, {
  166. "bean": "errorPageRegistrarBeanPostProcessor",
  167. "aliases": [],
  168. "scope": "singleton",
  169. "type": "org.springframework.boot.web.servlet.ErrorPageRegistrarBeanPostProcessor",
  170. "resource": "null",
  171. "dependencies": []
  172. }, {
  173. "bean": "org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration",
  174. "aliases": [],
  175. "scope": "singleton",
  176. "type": "org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration$$EnhancerBySpringCGLIB$$824a2d3d",
  177. "resource": "null",
  178. "dependencies": ["spring.mvc-org.springframework.boot.autoconfigure.web.WebMvcProperties"]
  179. }, {
  180. "bean": "dispatcherServlet",
  181. "aliases": [],
  182. "scope": "singleton",
  183. "type": "org.springframework.web.servlet.DispatcherServlet",
  184. "resource": "class path resource [org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfiguration$DispatcherServletConfiguration.class]",
  185. "dependencies": []
  186. }, {
  187. "bean": "spring.mvc-org.springframework.boot.autoconfigure.web.WebMvcProperties",
  188. "aliases": [],
  189. "scope": "singleton",
  190. "type": "org.springframework.boot.autoconfigure.web.WebMvcProperties",
  191. "resource": "null",
  192. "dependencies": []
  193. }, {
  194. "bean": "org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration",
  195. "aliases": [],
  196. "scope": "singleton",
  197. "type": "org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration$$EnhancerBySpringCGLIB$$fd39bc64",
  198. "resource": "null",
  199. "dependencies": ["serverProperties", "spring.mvc-org.springframework.boot.autoconfigure.web.WebMvcProperties"]
  200. }, {
  201. "bean": "dispatcherServletRegistration",
  202. "aliases": [],
  203. "scope": "singleton",
  204. "type": "org.springframework.boot.web.servlet.ServletRegistrationBean",
  205. "resource": "class path resource [org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration.class]",
  206. "dependencies": ["dispatcherServlet"]
  207. }, {
  208. "bean": "org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration",
  209. "aliases": [],
  210. "scope": "singleton",
  211. "type": "org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$$EnhancerBySpringCGLIB$$d158c03f",
  212. "resource": "null",
  213. "dependencies": []
  214. }, {
  215. "bean": "org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration",
  216. "aliases": [],
  217. "scope": "singleton",
  218. "type": "org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration$$EnhancerBySpringCGLIB$$4ce40e75",
  219. "resource": "null",
  220. "dependencies": []
  221. }, {
  222. "bean": "methodValidationPostProcessor",
  223. "aliases": [],
  224. "scope": "singleton",
  225. "type": "org.springframework.validation.beanvalidation.MethodValidationPostProcessor",
  226. "resource": "class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]",
  227. "dependencies": ["environment"]
  228. },
  229. ......
  230. {
  231. "bean": "org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration",
  232. "aliases": [],
  233. "scope": "singleton",
  234. "type": "org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration$$EnhancerBySpringCGLIB$$ec83a29e",
  235. "resource": "null",
  236. "dependencies": []
  237. }]
  238. }]

configprops

所有@ConfigurationProperties注解的配置信息,如文件上传的最大允许配置等。访问http://localhost/monitor/configprops,输出如下:

  1. {
  2. "environmentMvcEndpoint": {
  3. "prefix": "endpoints.env",
  4. "properties": {
  5. "path": "/env"
  6. }
  7. },
  8. "heapdumpMvcEndpoint": {
  9. "prefix": "endpoints.heapdump",
  10. "properties": {
  11. "enabled": true,
  12. "path": "/heapdump",
  13. "sensitive": true
  14. }
  15. },
  16. "managementServerProperties": {
  17. "prefix": "management",
  18. "properties": {
  19. "port": 80,
  20. "addApplicationContextHeader": true,
  21. "address": null,
  22. "contextPath": "/monitor",
  23. "ssl": null,
  24. "security": {
  25. "enabled": false,
  26. "roles": ["ACTUATOR"],
  27. "sessions": "STATELESS"
  28. }
  29. }
  30. },
  31. "spring.mvc-org.springframework.boot.autoconfigure.web.WebMvcProperties": {
  32. "prefix": "spring.mvc",
  33. "properties": {
  34. "locale": null,
  35. "mediaTypes": {},
  36. "localeResolver": "ACCEPT_HEADER",
  37. "messageCodesResolverFormat": null,
  38. "async": {
  39. "requestTimeout": null
  40. },
  41. "dispatchOptionsRequest": true,
  42. "servlet": {
  43. "loadOnStartup": -1
  44. },
  45. "ignoreDefaultModelOnRedirect": true,
  46. "dispatchTraceRequest": false,
  47. "staticPathPattern": "/**",
  48. "dateFormat": null,
  49. "view": {
  50. "prefix": null,
  51. "suffix": null
  52. },
  53. "logResolvedException": false,
  54. "throwExceptionIfNoHandlerFound": false
  55. }
  56. },
  57. "spring.http.multipart-org.springframework.boot.autoconfigure.web.MultipartProperties": {
  58. "prefix": "spring.http.multipart",
  59. "properties": {
  60. "enabled": true,
  61. "maxRequestSize": "10MB",
  62. "location": null,
  63. "resolveLazily": false,
  64. "fileSizeThreshold": "0",
  65. "maxFileSize": "1MB"
  66. }
  67. },
  68. "spring.http.encoding-org.springframework.boot.autoconfigure.web.HttpEncodingProperties": {
  69. "prefix": "spring.http.encoding",
  70. "properties": {
  71. "charset": "UTF-8",
  72. "mapping": null,
  73. "force": false,
  74. "forceResponse": false,
  75. "forceRequest": false
  76. }
  77. },
  78. "endpoints.health-org.springframework.boot.actuate.autoconfigure.HealthMvcEndpointProperties": {
  79. "prefix": "endpoints.health",
  80. "properties": {
  81. "mapping": {}
  82. }
  83. },
  84. "spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties": {
  85. "prefix": "spring.resources",
  86. "properties": {
  87. "staticLocations": ["/", "classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"],
  88. "addMappings": true,
  89. "chain": {
  90. "cache": true,
  91. "htmlApplicationCache": false,
  92. "gzipped": false,
  93. "strategy": {
  94. "fixed": {
  95. "enabled": false,
  96. "paths": ["/**"],
  97. "version": null
  98. },
  99. "content": {
  100. "enabled": false,
  101. "paths": ["/**"]
  102. }
  103. }
  104. },
  105. "cachePeriod": null
  106. }
  107. },
  108. "shutdownMvcEndpoint": {
  109. "prefix": "endpoints.shutdown",
  110. "properties": {
  111. "path": "/shutdown"
  112. }
  113. },
  114. "requestMappingEndpoint": {
  115. "prefix": "endpoints.mappings",
  116. "properties": {
  117. "id": "mappings",
  118. "enabled": true,
  119. "sensitive": true
  120. }
  121. },
  122. "autoConfigurationReportEndpoint": {
  123. "prefix": "endpoints.autoconfig",
  124. "properties": {
  125. "id": "autoconfig",
  126. "enabled": true,
  127. "sensitive": true
  128. }
  129. },
  130. "management.trace-org.springframework.boot.actuate.trace.TraceProperties": {
  131. "prefix": "management.trace",
  132. "properties": {
  133. "include": ["TIME_TAKEN", "ERRORS", "REQUEST_HEADERS", "COOKIES", "RESPONSE_HEADERS"]
  134. }
  135. },
  136. "management.info-org.springframework.boot.actuate.autoconfigure.InfoContributorProperties": {
  137. "prefix": "management.info",
  138. "properties": {
  139. "git": {
  140. "mode": "SIMPLE"
  141. }
  142. }
  143. },
  144. "loggersEndpoint": {
  145. "prefix": "endpoints.loggers",
  146. "properties": {
  147. "id": "loggers",
  148. "enabled": true,
  149. "sensitive": true
  150. }
  151. },
  152. "spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties": {
  153. "prefix": "spring.jackson",
  154. "properties": {
  155. "deserialization": {},
  156. "defaultPropertyInclusion": null,
  157. "propertyNamingStrategy": null,
  158. "locale": null,
  159. "serialization": {},
  160. "jodaDateTimeFormat": null,
  161. "mapper": {},
  162. "generator": {},
  163. "timeZone": null,
  164. "dateFormat": null,
  165. "parser": {}
  166. }
  167. },
  168. "shutdownEndpoint": {
  169. "prefix": "endpoints.shutdown",
  170. "properties": {
  171. "id": "shutdown",
  172. "enabled": true,
  173. "sensitive": true
  174. }
  175. },
  176. "endpoints.metrics.filter-org.springframework.boot.actuate.autoconfigure.MetricFilterProperties": {
  177. "prefix": "endpoints.metrics.filter",
  178. "properties": {
  179. "counterSubmissions": ["MERGED"],
  180. "gaugeSubmissions": ["MERGED"]
  181. }
  182. },
  183. "loggersMvcEndpoint": {
  184. "prefix": "endpoints.loggers",
  185. "properties": {
  186. "path": "/loggers"
  187. }
  188. },
  189. "dumpEndpoint": {
  190. "prefix": "endpoints.dump",
  191. "properties": {
  192. "id": "dump",
  193. "enabled": true,
  194. "sensitive": true
  195. }
  196. },
  197. "endpoints-org.springframework.boot.actuate.endpoint.EndpointProperties": {
  198. "prefix": "endpoints",
  199. "properties": {
  200. "enabled": true,
  201. "sensitive": null
  202. }
  203. },
  204. "metricsMvcEndpoint": {
  205. "prefix": "endpoints.metrics",
  206. "properties": {
  207. "path": "/metrics"
  208. }
  209. },
  210. "metricsEndpoint": {
  211. "prefix": "endpoints.metrics",
  212. "properties": {
  213. "id": "metrics",
  214. "enabled": true,
  215. "sensitive": true
  216. }
  217. },
  218. "healthEndpoint": {
  219. "prefix": "endpoints.health",
  220. "properties": {
  221. "id": "health",
  222. "enabled": true,
  223. "timeToLive": 1000,
  224. "sensitive": false
  225. }
  226. },
  227. "auditEventMvcEndpoint": {
  228. "prefix": "endpoints.auditevents",
  229. "properties": {
  230. "enabled": true,
  231. "path": "/auditevents",
  232. "sensitive": true
  233. }
  234. },
  235. "healthMvcEndpoint": {
  236. "prefix": "endpoints.health",
  237. "properties": {
  238. "path": "/health"
  239. }
  240. },
  241. "endpoints.cors-org.springframework.boot.actuate.autoconfigure.EndpointCorsProperties": {
  242. "prefix": "endpoints.cors",
  243. "properties": {
  244. "maxAge": 1800,
  245. "exposedHeaders": [],
  246. "allowedHeaders": [],
  247. "allowedOrigins": [],
  248. "allowedMethods": [],
  249. "allowCredentials": null
  250. }
  251. },
  252. "diskSpaceHealthIndicatorProperties": {
  253. "prefix": "management.health.diskspace",
  254. "properties": {
  255. "path": "C:\\Users\\Administrator\\Desktop\\01.Start-Spring-Boot\\.",
  256. "threshold": 10485760
  257. }
  258. },
  259. "beansEndpoint": {
  260. "prefix": "endpoints.beans",
  261. "properties": {
  262. "id": "beans",
  263. "enabled": true,
  264. "sensitive": true
  265. }
  266. },
  267. "traceEndpoint": {
  268. "prefix": "endpoints.trace",
  269. "properties": {
  270. "id": "trace",
  271. "enabled": true,
  272. "sensitive": true
  273. }
  274. },
  275. "auditEventsEndpoint": {
  276. "prefix": "endpoints.auditevents",
  277. "properties": {
  278. "enabled": true
  279. }
  280. },
  281. "endpoints.jmx-org.springframework.boot.actuate.autoconfigure.EndpointMBeanExportProperties": {
  282. "prefix": "endpoints.jmx",
  283. "properties": {
  284. "enabled": true,
  285. "uniqueNames": false,
  286. "domain": "",
  287. "staticNames": {}
  288. }
  289. },
  290. "spring.metrics.export-org.springframework.boot.actuate.metrics.export.MetricExportProperties": {
  291. "prefix": "spring.metrics.export",
  292. "properties": {
  293. "enabled": true,
  294. "redis": {
  295. "prefix": "spring.metrics.application.7f8f2ef33a0f173c075f96c8f5c5b4fd",
  296. "key": "******"
  297. },
  298. "aggregate": {
  299. "prefix": "application.7f8f2ef33a0f173c075f96c8f5c5b4fd",
  300. "keyPattern": "k.d"
  301. },
  302. "excludes": null,
  303. "statsd": {
  304. "host": null,
  305. "port": 8125,
  306. "prefix": null
  307. },
  308. "triggers": {},
  309. "includes": null
  310. }
  311. },
  312. "configurationPropertiesReportEndpoint": {
  313. "prefix": "endpoints.configprops",
  314. "properties": {
  315. "id": "configprops",
  316. "enabled": true,
  317. "sensitive": true
  318. }
  319. },
  320. "spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties": {
  321. "prefix": "spring.info",
  322. "properties": {
  323. "git": {
  324. "location": {}
  325. },
  326. "build": {
  327. "location": {}
  328. }
  329. }
  330. },
  331. "infoEndpoint": {
  332. "prefix": "endpoints.info",
  333. "properties": {
  334. "id": "info",
  335. "enabled": true,
  336. "sensitive": false
  337. }
  338. },
  339. "serverProperties": {
  340. "prefix": "server",
  341. "properties": {
  342. "undertow": {
  343. "maxHttpPostSize": 0,
  344. "bufferSize": null,
  345. "buffersPerRegion": null,
  346. "ioThreads": null,
  347. "workerThreads": null,
  348. "directBuffers": null,
  349. "accesslog": {
  350. "enabled": null,
  351. "pattern": "common",
  352. "prefix": "access_log.",
  353. "suffix": "log",
  354. "dir": "C:\\Users\\Administrator\\Desktop\\01.Start-Spring-Boot\\logs",
  355. "rotate": true
  356. }
  357. },
  358. "port": 80,
  359. "error": {
  360. "path": "/error",
  361. "includeStacktrace": "NEVER"
  362. },
  363. "maxHttpHeaderSize": 0,
  364. "jspServlet": null,
  365. "ssl": null,
  366. "maxHttpPostSize": 0,
  367. "jetty": {
  368. "maxHttpPostSize": 0,
  369. "acceptors": null,
  370. "selectors": null
  371. },
  372. "servletPath": "/",
  373. "tomcat": {
  374. "accesslog": {
  375. "enabled": false,
  376. "pattern": "common",
  377. "directory": "logs",
  378. "prefix": "access_log",
  379. "suffix": ".log",
  380. "rotate": true,
  381. "renameOnRotate": false,
  382. "fileDateFormat": ".yyyy-MM-dd",
  383. "requestAttributesEnabled": false,
  384. "buffered": true
  385. },
  386. "internalProxies": "10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|192\\.168\\.\\d{1,3}\\.\\d{1,3}|169\\.254\\.\\d{1,3}\\.\\d{1,3}|127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}",
  387. "protocolHeader": null,
  388. "protocolHeaderHttpsValue": "https",
  389. "portHeader": "X-Forwarded-Port",
  390. "remoteIpHeader": null,
  391. "basedir": null,
  392. "backgroundProcessorDelay": 30,
  393. "maxThreads": 0,
  394. "minSpareThreads": 0,
  395. "maxHttpPostSize": 0,
  396. "redirectContextRoot": null,
  397. "uriEncoding": null,
  398. "maxConnections": 0,
  399. "acceptCount": 0,
  400. "additionalTldSkipPatterns": []
  401. },
  402. "connectionTimeout": null,
  403. "session": {
  404. "timeout": null,
  405. "trackingModes": null,
  406. "persistent": false,
  407. "storeDir": null,
  408. "cookie": {
  409. "name": null,
  410. "domain": null,
  411. "path": null,
  412. "comment": null,
  413. "httpOnly": null,
  414. "secure": null,
  415. "maxAge": null
  416. }
  417. },
  418. "address": null,
  419. "contextParameters": {},
  420. "serverHeader": null,
  421. "useForwardHeaders": null,
  422. "contextPath": null,
  423. "displayName": "application"
  424. }
  425. },
  426. "management.health.status-org.springframework.boot.actuate.autoconfigure.HealthIndicatorProperties": {
  427. "prefix": "management.health.status",
  428. "properties": {
  429. "order": null
  430. }
  431. },
  432. "environmentEndpoint": {
  433. "prefix": "endpoints.env",
  434. "properties": {
  435. "id": "env",
  436. "enabled": true,
  437. "sensitive": true
  438. }
  439. }
  440. }

trace

/trace接口能查看最近的HTTP 请求和响应,在浏览器输入:http://localhost/monitor/trace,输出如下:

  1. [{
  2. "timestamp": 1525657638444,
  3. "info": {
  4. "method": "GET",
  5. "path": "/login;JSESSIONID=c1d0a83c-05fd-479c-ae6b-2ecc9b878a4a",
  6. "headers": {
  7. "request": {
  8. "host": "localhost",
  9. "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0",
  10. "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
  11. "accept-language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
  12. "accept-encoding": "gzip, deflate",
  13. "connection": "keep-alive",
  14. "upgrade-insecure-requests": "1",
  15. "pragma": "no-cache",
  16. "cache-control": "no-cache"
  17. },
  18. "response": {
  19. "X-Application-Context": "application:80",
  20. "status": "404"
  21. }
  22. },
  23. "timeTaken": "11"
  24. }
  25. }, {
  26. "timestamp": 1525657495017,
  27. "info": {
  28. "method": "GET",
  29. "path": "/monitor/beans",
  30. "headers": {
  31. "request": {
  32. "host": "localhost",
  33. "connection": "keep-alive",
  34. "upgrade-insecure-requests": "1",
  35. "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.10 Safari/537.36",
  36. "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
  37. "accept-encoding": "gzip, deflate, br",
  38. "accept-language": "zh-CN,zh;q=0.9,en;q=0.8"
  39. },
  40. "response": {
  41. "X-Application-Context": "application:80",
  42. "Content-Type": "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8",
  43. "Transfer-Encoding": "chunked",
  44. "Date": "Mon, 07 May 2018 01:44:55 GMT",
  45. "status": "200"
  46. }
  47. },
  48. "timeTaken": "609"
  49. }
  50. }, {
  51. "timestamp": 1525657402454,
  52. "info": {
  53. "method": "GET",
  54. "path": "/favicon.ico",
  55. "headers": {
  56. "request": {
  57. "host": "localhost",
  58. "connection": "keep-alive",
  59. "pragma": "no-cache",
  60. "cache-control": "no-cache",
  61. "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.10 Safari/537.36",
  62. "accept": "image/webp,image/apng,image/*,*/*;q=0.8",
  63. "referer": "http://localhost/monitor/autoconfig",
  64. "accept-encoding": "gzip, deflate, br",
  65. "accept-language": "zh-CN,zh;q=0.9,en;q=0.8"
  66. },
  67. "response": {
  68. "X-Application-Context": "application:80",
  69. "Last-Modified": "Wed, 29 Nov 2017 01:54:48 GMT",
  70. "Accept-Ranges": "bytes",
  71. "Content-Type": "application/octet-stream",
  72. "Content-Length": "946",
  73. "Date": "Mon, 07 May 2018 01:43:22 GMT",
  74. "status": "200"
  75. }
  76. },
  77. "timeTaken": "21"
  78. }
  79. }, {
  80. "timestamp": 1525657402076,
  81. "info": {
  82. "method": "GET",
  83. "path": "/monitor/autoconfig",
  84. "headers": {
  85. "request": {
  86. "host": "localhost",
  87. "connection": "keep-alive",
  88. "cache-control": "max-age=0",
  89. "upgrade-insecure-requests": "1",
  90. "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.10 Safari/537.36",
  91. "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
  92. "accept-encoding": "gzip, deflate, br",
  93. "accept-language": "zh-CN,zh;q=0.9,en;q=0.8"
  94. },
  95. "response": {
  96. "X-Application-Context": "application:80",
  97. "Content-Type": "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8",
  98. "Transfer-Encoding": "chunked",
  99. "Date": "Mon, 07 May 2018 01:43:22 GMT",
  100. "status": "200"
  101. }
  102. },
  103. "timeTaken": "300"
  104. }
  105. }]

dump

获取某一时刻虚拟机线程栈信息。线程栈表示某一时刻虚拟机正在做的事情,访问http://localhost/monitor/dump,输出如下(截取部分):

  1. [{
  2. "threadName": "DestroyJavaVM",
  3. "threadId": 32,
  4. "blockedTime": -1,
  5. "blockedCount": 0,
  6. "waitedTime": -1,
  7. "waitedCount": 0,
  8. "lockName": null,
  9. "lockOwnerId": -1,
  10. "lockOwnerName": null,
  11. "inNative": false,
  12. "suspended": false,
  13. "threadState": "RUNNABLE",
  14. "stackTrace": [],
  15. "lockedMonitors": [],
  16. "lockedSynchronizers": [],
  17. "lockInfo": null
  18. }, {
  19. "threadName": "http-nio-80-AsyncTimeout",
  20. "threadId": 30,
  21. "blockedTime": -1,
  22. "blockedCount": 0,
  23. "waitedTime": -1,
  24. "waitedCount": 14903,
  25. "lockName": null,
  26. "lockOwnerId": -1,
  27. "lockOwnerName": null,
  28. "inNative": false,
  29. "suspended": false,
  30. "threadState": "TIMED_WAITING",
  31. "stackTrace": [{
  32. "methodName": "sleep",
  33. "fileName": "Thread.java",
  34. "lineNumber": -2,
  35. "className": "java.lang.Thread",
  36. "nativeMethod": true
  37. }, {
  38. "methodName": "run",
  39. "fileName": "AbstractProtocol.java",
  40. "lineNumber": 1211,
  41. "className": "org.apache.coyote.AbstractProtocol$AsyncTimeout",
  42. "nativeMethod": false
  43. }, {
  44. "methodName": "run",
  45. "fileName": "Thread.java",
  46. "lineNumber": 745,
  47. "className": "java.lang.Thread",
  48. "nativeMethod": false
  49. }],
  50. "lockedMonitors": [],
  51. "lockedSynchronizers": [],
  52. "lockInfo": null
  53. }, {
  54. "threadName": "http-nio-80-Acceptor-0",
  55. "threadId": 29,
  56. "blockedTime": -1,
  57. "blockedCount": 0,
  58. "waitedTime": -1,
  59. "waitedCount": 0,
  60. "lockName": null,
  61. "lockOwnerId": -1,
  62. "lockOwnerName": null,
  63. "inNative": true,
  64. "suspended": false,
  65. "threadState": "RUNNABLE",
  66. "stackTrace": [{
  67. "methodName": "accept0",
  68. "fileName": "ServerSocketChannelImpl.java",
  69. "lineNumber": -2,
  70. "className": "sun.nio.ch.ServerSocketChannelImpl",
  71. "nativeMethod": true
  72. }, {
  73. "methodName": "accept",
  74. "fileName": "ServerSocketChannelImpl.java",
  75. "lineNumber": 250,
  76. "className": "sun.nio.ch.ServerSocketChannelImpl",
  77. "nativeMethod": false
  78. }, {
  79. "methodName": "run",
  80. "fileName": "NioEndpoint.java",
  81. "lineNumber": 455,
  82. "className": "org.apache.tomcat.util.net.NioEndpoint$Acceptor",
  83. "nativeMethod": false
  84. }, {
  85. "methodName": "run",
  86. "fileName": "Thread.java",
  87. "lineNumber": 745,
  88. "className": "java.lang.Thread",
  89. "nativeMethod": false
  90. }],
  91. "lockedMonitors": [{
  92. "className": "java.lang.Object",
  93. "identityHashCode": 1985974129,
  94. "lockedStackDepth": 1,
  95. "lockedStackFrame": {
  96. "methodName": "accept",
  97. "fileName": "ServerSocketChannelImpl.java",
  98. "lineNumber": 250,
  99. "className": "sun.nio.ch.ServerSocketChannelImpl",
  100. "nativeMethod": false
  101. }
  102. }],
  103. "lockedSynchronizers": [],
  104. "lockInfo": null
  105. }, {
  106. "threadName": "http-nio-80-ClientPoller-1",
  107. "threadId": 28,
  108. "blockedTime": -1,
  109. "blockedCount": 6,
  110. "waitedTime": -1,
  111. "waitedCount": 0,
  112. "lockName": null,
  113. "lockOwnerId": -1,
  114. "lockOwnerName": null,
  115. "inNative": true,
  116. "suspended": false,
  117. "threadState": "RUNNABLE",
  118. "stackTrace": [{
  119. "methodName": "poll0",
  120. "fileName": "WindowsSelectorImpl.java",
  121. "lineNumber": -2,
  122. "className": "sun.nio.ch.WindowsSelectorImpl$SubSelector",
  123. "nativeMethod": true
  124. }, {
  125. "methodName": "poll",
  126. "fileName": "WindowsSelectorImpl.java",
  127. "lineNumber": 296,
  128. "className": "sun.nio.ch.WindowsSelectorImpl$SubSelector",
  129. "nativeMethod": false
  130. }, {
  131. "methodName": "access$400",
  132. "fileName": "WindowsSelectorImpl.java",
  133. "lineNumber": 278,
  134. "className": "sun.nio.ch.WindowsSelectorImpl$SubSelector",
  135. "nativeMethod": false
  136. }, {
  137. "methodName": "doSelect",
  138. "fileName": "WindowsSelectorImpl.java",
  139. "lineNumber": 159,
  140. "className": "sun.nio.ch.WindowsSelectorImpl",
  141. "nativeMethod": false
  142. }, {
  143. "methodName": "lockAndDoSelect",
  144. "fileName": "SelectorImpl.java",
  145. "lineNumber": 87,
  146. "className": "sun.nio.ch.SelectorImpl",
  147. "nativeMethod": false
  148. }, {
  149. "methodName": "select",
  150. "fileName": "SelectorImpl.java",
  151. "lineNumber": 98,
  152. "className": "sun.nio.ch.SelectorImpl",
  153. "nativeMethod": false
  154. }, {
  155. "methodName": "run",
  156. "fileName": "NioEndpoint.java",
  157. "lineNumber": 793,
  158. "className": "org.apache.tomcat.util.net.NioEndpoint$Poller",
  159. "nativeMethod": false
  160. }, {
  161. "methodName": "run",
  162. "fileName": "Thread.java",
  163. "lineNumber": 745,
  164. "className": "java.lang.Thread",
  165. "nativeMethod": false
  166. }],
  167. "lockedMonitors": [{
  168. "className": "sun.nio.ch.Util$2",
  169. "identityHashCode": 511554453,
  170. "lockedStackDepth": 4,
  171. "lockedStackFrame": {
  172. "methodName": "lockAndDoSelect",
  173. "fileName": "SelectorImpl.java",
  174. "lineNumber": 87,
  175. "className": "sun.nio.ch.SelectorImpl",
  176. "nativeMethod": false
  177. }
  178. }, {
  179. "className": "java.util.Collections$UnmodifiableSet",
  180. "identityHashCode": 563515370,
  181. "lockedStackDepth": 4,
  182. "lockedStackFrame": {
  183. "methodName": "lockAndDoSelect",
  184. "fileName": "SelectorImpl.java",
  185. "lineNumber": 87,
  186. "className": "sun.nio.ch.SelectorImpl",
  187. "nativeMethod": false
  188. }
  189. }, {
  190. "className": "sun.nio.ch.WindowsSelectorImpl",
  191. "identityHashCode": 761235575,
  192. "lockedStackDepth": 4,
  193. "lockedStackFrame": {
  194. "methodName": "lockAndDoSelect",
  195. "fileName": "SelectorImpl.java",
  196. "lineNumber": 87,
  197. "className": "sun.nio.ch.SelectorImpl",
  198. "nativeMethod": false
  199. }
  200. }],
  201. "lockedSynchronizers": [],
  202. "lockInfo": null
  203. },
  204. ......
  205. {
  206. "threadName": "Finalizer",
  207. "threadId": 3,
  208. "blockedTime": -1,
  209. "blockedCount": 202,
  210. "waitedTime": -1,
  211. "waitedCount": 51,
  212. "lockName": "java.lang.ref.ReferenceQueue$Lock@bd5f3f3",
  213. "lockOwnerId": -1,
  214. "lockOwnerName": null,
  215. "inNative": false,
  216. "suspended": false,
  217. "threadState": "WAITING",
  218. "stackTrace": [{
  219. "methodName": "wait",
  220. "fileName": "Object.java",
  221. "lineNumber": -2,
  222. "className": "java.lang.Object",
  223. "nativeMethod": true
  224. }, {
  225. "methodName": "remove",
  226. "fileName": "ReferenceQueue.java",
  227. "lineNumber": 135,
  228. "className": "java.lang.ref.ReferenceQueue",
  229. "nativeMethod": false
  230. }, {
  231. "methodName": "remove",
  232. "fileName": "ReferenceQueue.java",
  233. "lineNumber": 151,
  234. "className": "java.lang.ref.ReferenceQueue",
  235. "nativeMethod": false
  236. }, {
  237. "methodName": "run",
  238. "fileName": "Finalizer.java",
  239. "lineNumber": 209,
  240. "className": "java.lang.ref.Finalizer$FinalizerThread",
  241. "nativeMethod": false
  242. }],
  243. "lockedMonitors": [],
  244. "lockedSynchronizers": [],
  245. "lockInfo": {
  246. "className": "java.lang.ref.ReferenceQueue$Lock",
  247. "identityHashCode": 198570995
  248. }
  249. }]

env

显示Spring Boot环境变量,如使用的JDK版本、加载的jar包、配置文件信息、日志文件信息。访问,输出如下:

  1. {
  2. "profiles": [],
  3. "server.ports": {
  4. "local.server.port": 80
  5. },
  6. "servletContextInitParams": {},
  7. "systemProperties": {
  8. "java.runtime.name": "Java(TM) SE Runtime Environment",
  9. "sun.boot.library.path": "C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\bin",
  10. "java.vm.version": "24.80-b11",
  11. "java.vm.vendor": "Oracle Corporation",
  12. "java.vendor.url": "http://java.oracle.com/",
  13. "path.separator": ";",
  14. "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",
  15. "file.encoding.pkg": "sun.io",
  16. "user.country": "CN",
  17. "user.script": "",
  18. "sun.java.launcher": "SUN_STANDARD",
  19. "sun.os.patch.level": "",
  20. "PID": "15184",
  21. "java.vm.specification.name": "Java Virtual Machine Specification",
  22. "user.dir": "C:\\Users\\Administrator\\Desktop\\01.Start-Spring-Boot",
  23. "java.runtime.version": "1.7.0_80-b15",
  24. "java.awt.graphicsenv": "sun.awt.Win32GraphicsEnvironment",
  25. "org.jboss.logging.provider": "slf4j",
  26. "java.endorsed.dirs": "C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\endorsed",
  27. "os.arch": "amd64",
  28. "java.io.tmpdir": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\",
  29. "line.separator": "\r\n",
  30. "java.vm.specification.vendor": "Oracle Corporation",
  31. "user.variant": "",
  32. "os.name": "Windows 8.1",
  33. "sun.jnu.encoding": "GBK",
  34. "spring.beaninfo.ignore": "true",
  35. "java.library.path": "C:\\Program Files\\Java\\jdk1.7.0_80\\bin;C:\\Windows\\Sun\\Java\\bin;C:\\Windows\\system32;C:\\Windows;C:/Program Files/Java/jre1.8.0_31/bin/server;C:/Program Files/Java/jre1.8.0_31/bin;C:/Program Files/Java/jre1.8.0_31/lib/amd64;f:\\app\\Administrator\\product\\11.2.0\\client_1\\bin;f:\\app\\Administrator\\product\\11.2.0\\dbhome_1\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\nodejs\\;C:\\Program Files\\Git\\cmd;\"%JAVA_HOME%\\bin;%JAVA_HOME%\\jre\\bin\";%M2_HOME%\\bin;C:\\Program Files\\TortoiseSVN\\bin;C:\\Program Files\\PuTTY\\;C:\\ProgramData\\chocolatey\\bin;C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Administrator\\AppData\\Roaming\\npm;\"C:\\Program Files\\Java\\jdk1.8.0_31\\bin;C:\\Program Files\\Java\\jdk1.8.0_31\\jre\\bin\";D:\\Program Files\\apache-maven-3.3.9-bin\\apache-maven-3.3.9\\bin;C:\\Program Files\\cmder;;D:\\Program Files\\Oxygen;;.",
  36. "java.specification.name": "Java Platform API Specification",
  37. "java.class.version": "51.0",
  38. "sun.management.compiler": "HotSpot 64-Bit Tiered Compilers",
  39. "os.version": "6.3",
  40. "user.home": "C:\\Users\\Administrator",
  41. "catalina.useNaming": "false",
  42. "user.timezone": "Asia/Shanghai",
  43. "java.awt.printerjob": "sun.awt.windows.WPrinterJob",
  44. "file.encoding": "UTF-8",
  45. "java.specification.version": "1.7",
  46. "catalina.home": "C:\\Users\\Administrator\\AppData\\Local\\Temp\\tomcat.2042919348800278549.80",
  47. "java.class.path": "C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\resources.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\rt.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\jsse.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\jce.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\charsets.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\jfr.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\access-bridge-64.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\dnsns.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\jaccess.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\localedata.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\sunec.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\sunjce_provider.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\sunmscapi.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext\\zipfs.jar;C:\\Users\\Administrator\\Desktop\\01.Start-Spring-Boot\\target\\classes;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot-starter-web\\1.5.9.RELEASE\\spring-boot-starter-web-1.5.9.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot-starter\\1.5.9.RELEASE\\spring-boot-starter-1.5.9.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot\\1.5.9.RELEASE\\spring-boot-1.5.9.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot-autoconfigure\\1.5.9.RELEASE\\spring-boot-autoconfigure-1.5.9.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot-starter-logging\\1.5.9.RELEASE\\spring-boot-starter-logging-1.5.9.RELEASE.jar;D:\\m2\\repository\\ch\\qos\\logback\\logback-classic\\1.1.11\\logback-classic-1.1.11.jar;D:\\m2\\repository\\ch\\qos\\logback\\logback-core\\1.1.11\\logback-core-1.1.11.jar;D:\\m2\\repository\\org\\slf4j\\jcl-over-slf4j\\1.7.25\\jcl-over-slf4j-1.7.25.jar;D:\\m2\\repository\\org\\slf4j\\jul-to-slf4j\\1.7.25\\jul-to-slf4j-1.7.25.jar;D:\\m2\\repository\\org\\slf4j\\log4j-over-slf4j\\1.7.25\\log4j-over-slf4j-1.7.25.jar;D:\\m2\\repository\\org\\yaml\\snakeyaml\\1.17\\snakeyaml-1.17.jar;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot-starter-tomcat\\1.5.9.RELEASE\\spring-boot-starter-tomcat-1.5.9.RELEASE.jar;D:\\m2\\repository\\org\\apache\\tomcat\\embed\\tomcat-embed-core\\8.5.23\\tomcat-embed-core-8.5.23.jar;D:\\m2\\repository\\org\\apache\\tomcat\\tomcat-annotations-api\\8.5.23\\tomcat-annotations-api-8.5.23.jar;D:\\m2\\repository\\org\\apache\\tomcat\\embed\\tomcat-embed-el\\8.5.23\\tomcat-embed-el-8.5.23.jar;D:\\m2\\repository\\org\\apache\\tomcat\\embed\\tomcat-embed-websocket\\8.5.23\\tomcat-embed-websocket-8.5.23.jar;D:\\m2\\repository\\org\\hibernate\\hibernate-validator\\5.3.6.Final\\hibernate-validator-5.3.6.Final.jar;D:\\m2\\repository\\javax\\validation\\validation-api\\1.1.0.Final\\validation-api-1.1.0.Final.jar;D:\\m2\\repository\\org\\jboss\\logging\\jboss-logging\\3.3.1.Final\\jboss-logging-3.3.1.Final.jar;D:\\m2\\repository\\com\\fasterxml\\classmate\\1.3.4\\classmate-1.3.4.jar;D:\\m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-databind\\2.8.10\\jackson-databind-2.8.10.jar;D:\\m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-annotations\\2.8.0\\jackson-annotations-2.8.0.jar;D:\\m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-core\\2.8.10\\jackson-core-2.8.10.jar;D:\\m2\\repository\\org\\springframework\\spring-web\\4.3.13.RELEASE\\spring-web-4.3.13.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\spring-aop\\4.3.13.RELEASE\\spring-aop-4.3.13.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\spring-beans\\4.3.13.RELEASE\\spring-beans-4.3.13.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\spring-context\\4.3.13.RELEASE\\spring-context-4.3.13.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\spring-webmvc\\4.3.13.RELEASE\\spring-webmvc-4.3.13.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\spring-expression\\4.3.13.RELEASE\\spring-expression-4.3.13.RELEASE.jar;D:\\m2\\repository\\org\\slf4j\\slf4j-api\\1.7.25\\slf4j-api-1.7.25.jar;D:\\m2\\repository\\org\\springframework\\spring-core\\4.3.13.RELEASE\\spring-core-4.3.13.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot-starter-actuator\\1.5.9.RELEASE\\spring-boot-starter-actuator-1.5.9.RELEASE.jar;D:\\m2\\repository\\org\\springframework\\boot\\spring-boot-actuator\\1.5.9.RELEASE\\spring-boot-actuator-1.5.9.RELEASE.jar",
  48. "user.name": "Administrator",
  49. "java.vm.specification.version": "1.7",
  50. "sun.java.command": "com.springboot.demo.DemoApplication",
  51. "java.home": "C:\\Program Files\\Java\\jdk1.7.0_80\\jre",
  52. "sun.arch.data.model": "64",
  53. "user.language": "zh",
  54. "java.specification.vendor": "Oracle Corporation",
  55. "awt.toolkit": "sun.awt.windows.WToolkit",
  56. "java.vm.info": "mixed mode",
  57. "java.version": "1.7.0_80",
  58. "java.ext.dirs": "C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\ext;C:\\Windows\\Sun\\Java\\lib\\ext",
  59. "sun.boot.class.path": "C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\resources.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\rt.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\sunrsasign.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\jsse.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\jce.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\charsets.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\lib\\jfr.jar;C:\\Program Files\\Java\\jdk1.7.0_80\\jre\\classes",
  60. "java.awt.headless": "true",
  61. "java.vendor": "Oracle Corporation",
  62. "catalina.base": "C:\\Users\\Administrator\\AppData\\Local\\Temp\\tomcat.2042919348800278549.80",
  63. "file.separator": "\\",
  64. "java.vendor.url.bug": "http://bugreport.sun.com/bugreport/",
  65. "sun.io.unicode.encoding": "UnicodeLittle",
  66. "sun.cpu.endian": "little",
  67. "sun.desktop": "windows",
  68. "sun.cpu.isalist": "amd64"
  69. },
  70. "systemEnvironment": {
  71. "USERPROFILE": "C:\\Users\\Administrator",
  72. "ProgramData": "C:\\ProgramData",
  73. "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC",
  74. "JAVA_HOME": "C:\\Program Files\\Java\\jdk1.8.0_31",
  75. "ProgramFiles(x86)": "C:\\Program Files (x86)",
  76. "ChocolateyLastPathUpdate": "周四 4月 26 09:03:47 2018",
  77. "TEMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp",
  78. "SystemDrive": "C:",
  79. "ProgramFiles": "C:\\Program Files",
  80. "Path": "C:/Program Files/Java/jre1.8.0_31/bin/server;C:/Program Files/Java/jre1.8.0_31/bin;C:/Program Files/Java/jre1.8.0_31/lib/amd64;f:\\app\\Administrator\\product\\11.2.0\\client_1\\bin;f:\\app\\Administrator\\product\\11.2.0\\dbhome_1\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\nodejs\\;C:\\Program Files\\Git\\cmd;\"%JAVA_HOME%\\bin;%JAVA_HOME%\\jre\\bin\";%M2_HOME%\\bin;C:\\Program Files\\TortoiseSVN\\bin;C:\\Program Files\\PuTTY\\;C:\\ProgramData\\chocolatey\\bin;C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Administrator\\AppData\\Roaming\\npm;\"C:\\Program Files\\Java\\jdk1.8.0_31\\bin;C:\\Program Files\\Java\\jdk1.8.0_31\\jre\\bin\";D:\\Program Files\\apache-maven-3.3.9-bin\\apache-maven-3.3.9\\bin;C:\\Program Files\\cmder;;D:\\Program Files\\Oxygen;",
  81. "HOMEDRIVE": "C:",
  82. "PROCESSOR_REVISION": "4e03",
  83. "=C:": "C:\\",
  84. "USERDOMAIN": "SC-201802012049",
  85. "ALLUSERSPROFILE": "C:\\ProgramData",
  86. "ProgramW6432": "C:\\Program Files",
  87. "PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 78 Stepping 3, GenuineIntel",
  88. "SESSIONNAME": "Console",
  89. "FPS_BROWSER_USER_PROFILE_STRING": "Default",
  90. "TMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp",
  91. "PROCESSOR_ARCHITECTURE": "AMD64",
  92. "CommonProgramFiles": "C:\\Program Files\\Common Files",
  93. "CLASSPATH": ".;C:\\Program Files\\Java\\jdk1.8.0_31\\lib;C:\\Program Files\\Java\\jdk1.8.0_31\\lib\\tools.jar",
  94. "=::": "::\\",
  95. "LOGONSERVER": "\\\\SC-201802012049",
  96. "M2_HOME": "D:\\Program Files\\apache-maven-3.3.9-bin\\apache-maven-3.3.9",
  97. "OS": "Windows_NT",
  98. "HOMEPATH": "\\Users\\Administrator",
  99. "PROCESSOR_LEVEL": "6",
  100. "FPS_BROWSER_APP_PROFILE_STRING": "Internet Explorer",
  101. "CommonProgramW6432": "C:\\Program Files\\Common Files",
  102. "USERDOMAIN_ROAMINGPROFILE": "SC-201802012049",
  103. "LOCALAPPDATA": "C:\\Users\\Administrator\\AppData\\Local",
  104. "COMPUTERNAME": "SC-201802012049",
  105. "windir": "C:\\Windows",
  106. "SystemRoot": "C:\\Windows",
  107. "asl.log": "Destination=file",
  108. "NUMBER_OF_PROCESSORS": "4",
  109. "USERNAME": "Administrator",
  110. "PUBLIC": "C:\\Users\\Public",
  111. "PSModulePath": "C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules",
  112. "CommonProgramFiles(x86)": "C:\\Program Files (x86)\\Common Files",
  113. "ComSpec": "C:\\Windows\\system32\\cmd.exe",
  114. "ChocolateyInstall": "C:\\ProgramData\\chocolatey",
  115. "APPDATA": "C:\\Users\\Administrator\\AppData\\Roaming"
  116. },
  117. "applicationConfig: [classpath:/application.yml]": {
  118. "server.port": 80,
  119. "management.security.enabled": false,
  120. "management.port": 80,
  121. "management.context-path": "/monitor",
  122. "endpoints.shutdown.enabled": true
  123. }
  124. }

health

查看所在应用的健康状态, 如磁盘、数据源、Redis 、Elasticsearch等。健康状态分为UP(正常)和DOWN(故障)状态。访问http://localhost/monitor/health,显示如下:

  1. {
  2. "status": "UP",
  3. "diskSpace": {
  4. "status": "UP",
  5. "total": 107380994048,
  6. "free": 63853707264,
  7. "threshold": 10485760
  8. }
  9. }

mappings

输出所有通过注解@RequestMapping设置的URL映射,可以通过此来查看URL对应的Controller。访问http://localhost/monitor/mappings,显示如下:

  1. {
  2. "/webjars/**": {
  3. "bean": "resourceHandlerMapping"
  4. },
  5. "/**": {
  6. "bean": "resourceHandlerMapping"
  7. },
  8. "/**/favicon.ico": {
  9. "bean": "faviconHandlerMapping"
  10. },
  11. "{[/]}": {
  12. "bean": "requestMappingHandlerMapping",
  13. "method": "java.lang.String com.springboot.demo.DemoApplication.index()"
  14. },
  15. "{[/error]}": {
  16. "bean": "requestMappingHandlerMapping",
  17. "method": "public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)"
  18. },
  19. "{[/error],produces=[text/html]}": {
  20. "bean": "requestMappingHandlerMapping",
  21. "method": "public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)"
  22. },
  23. "{[/monitor/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  24. "bean": "endpointHandlerMapping",
  25. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.get(java.lang.String)"
  26. },
  27. "{[/monitor/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  28. "bean": "endpointHandlerMapping",
  29. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)"
  30. },
  31. "{[/monitor/loggers || /monitor/loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  32. "bean": "endpointHandlerMapping",
  33. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  34. },
  35. "{[/monitor/shutdown || /monitor/shutdown.json],methods=[POST],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  36. "bean": "endpointHandlerMapping",
  37. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.ShutdownMvcEndpoint.invoke()"
  38. },
  39. "{[/monitor/trace || /monitor/trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  40. "bean": "endpointHandlerMapping",
  41. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  42. },
  43. "{[/monitor/heapdump || /monitor/heapdump.json],methods=[GET],produces=[application/octet-stream]}": {
  44. "bean": "endpointHandlerMapping",
  45. "method": "public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException"
  46. },
  47. "{[/monitor/autoconfig || /monitor/autoconfig.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  48. "bean": "endpointHandlerMapping",
  49. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  50. },
  51. "{[/monitor/beans || /monitor/beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  52. "bean": "endpointHandlerMapping",
  53. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  54. },
  55. "{[/monitor/mappings || /monitor/mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  56. "bean": "endpointHandlerMapping",
  57. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  58. },
  59. "{[/monitor/health || /monitor/health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  60. "bean": "endpointHandlerMapping",
  61. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)"
  62. },
  63. "{[/monitor/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  64. "bean": "endpointHandlerMapping",
  65. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)"
  66. },
  67. "{[/monitor/metrics || /monitor/metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  68. "bean": "endpointHandlerMapping",
  69. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  70. },
  71. "{[/monitor/dump || /monitor/dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  72. "bean": "endpointHandlerMapping",
  73. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  74. },
  75. "{[/monitor/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  76. "bean": "endpointHandlerMapping",
  77. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)"
  78. },
  79. "{[/monitor/env || /monitor/env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  80. "bean": "endpointHandlerMapping",
  81. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  82. },
  83. "{[/monitor/info || /monitor/info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  84. "bean": "endpointHandlerMapping",
  85. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  86. },
  87. "{[/monitor/configprops || /monitor/configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  88. "bean": "endpointHandlerMapping",
  89. "method": "public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()"
  90. },
  91. "{[/monitor/auditevents || /monitor/auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}": {
  92. "bean": "endpointHandlerMapping",
  93. "method": "public org.springframework.http.ResponseEntity<?> org.springframework.boot.actuate.endpoint.mvc.AuditEventsMvcEndpoint.findByPrincipalAndAfterAndType(java.lang.String,java.util.Date,java.lang.String)"
  94. }
  95. }

metrics

显示Spring Boot的性能指标,如己有内存、未占用内存、垃圾回收次数、类信息等。访问http://localhost/monitor/metrics,输出如下:

  1. {
  2. "mem": 245361,
  3. "mem.free": 76255,
  4. "processors": 4,
  5. "instance.uptime": 15927377,
  6. "uptime": 15932920,
  7. "systemload.average": -1.0,
  8. "heap.committed": 209408,
  9. "heap.init": 122659,
  10. "heap.used": 133152,
  11. "heap": 1745920,
  12. "nonheap.committed": 36480,
  13. "nonheap.init": 24000,
  14. "nonheap.used": 35953,
  15. "nonheap": 133120,
  16. "threads.peak": 24,
  17. "threads.daemon": 20,
  18. "threads.totalStarted": 27,
  19. "threads": 22,
  20. "classes": 6107,
  21. "classes.loaded": 6107,
  22. "classes.unloaded": 0,
  23. "gc.ps_scavenge.count": 5,
  24. "gc.ps_scavenge.time": 73,
  25. "gc.ps_marksweep.count": 0,
  26. "gc.ps_marksweep.time": 0,
  27. "httpsessions.max": -1,
  28. "httpsessions.active": 0,
  29. "counter.status.200.monitor.autoconfig": 2,
  30. "counter.status.200.monitor.beans": 2,
  31. "counter.status.200.monitor.configprops": 1,
  32. "counter.status.200.monitor.dump": 4,
  33. "counter.status.200.monitor.env": 1,
  34. "counter.status.200.monitor.health": 1,
  35. "counter.status.200.monitor.info": 1,
  36. "counter.status.200.monitor.loggers": 1,
  37. "counter.status.200.monitor.mappings": 1,
  38. "counter.status.200.monitor.trace": 3,
  39. "counter.status.200.star-star.favicon.ico": 3,
  40. "counter.status.404.star-star": 2,
  41. "gauge.response.monitor.autoconfig": 14.0,
  42. "gauge.response.monitor.beans": 42.0,
  43. "gauge.response.monitor.configprops": 440.0,
  44. "gauge.response.monitor.dump": 62.0,
  45. "gauge.response.monitor.env": 14.0,
  46. "gauge.response.monitor.health": 22.0,
  47. "gauge.response.monitor.info": 26.0,
  48. "gauge.response.monitor.loggers": 237.0,
  49. "gauge.response.monitor.mappings": 7.0,
  50. "gauge.response.monitor.trace": 8.0,
  51. "gauge.response.star-star": 12.0,
  52. "gauge.response.star-star.favicon.ico": 6.0
  53. }

/metrics接口提供的信息进行简单分类如下表:

分类 前缀 报告内容
垃圾收集器 gc. 已经发生过的垃圾收集次数,以及垃圾收集所耗费的时间,适用于标记-清理垃圾收集器和并行垃圾收集器(数据源自java.lang.management. GarbageCollectorMXBean)
内存 mem. 分配给应用程序的内存数量和空闲的内存数量(数据源自java.lang. Runtime)
heap. 当前内存用量(数据源自java.lang.management.MemoryUsage)
类加载器 classes. JVM类加载器加载与卸载的类的数量(数据源自java.lang. management.ClassLoadingMXBean)
系统 processors、instance.uptime、uptime、systemload.average 系统信息,例如处理器数量(数据源自java.lang.Runtime)、运行时间(数据源自java.lang.management.RuntimeMXBean)、平均负载(数据源自java.lang.management.OperatingSystemMXBean)
线程池 thread. 线程、守护线程的数量,以及JVM启动后的线程数量峰值(数据源自 java.lang .management.ThreadMXBean)
数据源 datasource. 数据源连接的数量(源自数据源的元数据,仅当Spring应用程序上下文里存在 DataSource Bean 的时候才会有这个信息)
Tomcat 会话 httpsessions.* Tomcat的活跃会话数和最大会话数(数据源自嵌入式Tomcat的Bean,仅在使用嵌入式Tomcat服务器运行应用程序时才有这个信息)
HTTP counter.status.、gauge.response. 多种应用程序服务HTTP请求的度量值与计数器

HTTP的计数器和度量值需要做一点说明。counter.status后的值是HTTP状态码,随后是所请求的路径。举个例子,counter.status.200.metrics 表明/metrics端点返回 200(OK) 状态码的次数。

HTTP的度量信息在结构上也差不多,却在报告另一类信息。它们全部以gauge.response开头,表明这是HTTP响应的度量信息。前缀后是对应的路径。度量值是以毫秒为单位的时间,反映了最近处理该路径请求的耗时。

这里还有几个特殊的值需要注意。root路径指向的是根路径或/star-star代表了那些Spring认为是静态资源的路径,包括图片、JavaScript和样式表,其中还包含了那些找不到的资源。这就是为什么你经常会看到counter.status.404.star-star,这是返回了HTTP 404 (NOT FOUND)状态的请求数。

/metrics接口会返回所有的可用度量值,但你也可能只对某个值感兴趣。要获取单个值,请求时可以在URL后加上对应的键名。例如,要查看空闲内存大小,可以向/metrics/mem.free发一个GET请求。

定制Actuator

修改接口ID

每个Actuator接口都有一个ID用来决定接口的路径,比方说,/beans接口的默认ID就是beans。比如要修改/beans/instances,则设置如下:

  1. endpoints:
  2. beans:
  3. id: instances

启用和禁用接口

虽然Actuator的接口都很有用,但你不一定需要全部这些接口。默认情况下,所有接口(除了/shutdown)都启用。比如要禁用 /metrics 接口,则可以设置如下:

  1. endpoints:
  2. metrics:
  3. enabled: false

如果你只想打开一两个接口,那就先禁用全部接口,然后启用那几个你要的,这样更方便。

  1. endpoints:
  2. enabled: false
  3. metrics:
  4. enabled: true

参考文章: https://www.jianshu.com/p/af9738634a21 SpringBoot 2.x Actuator