概述
-
Spring-boot-starter-actuator 是用于監(jiān)控與管理的,只需引入依賴庫(kù)就能為應(yīng)用添加監(jiān)控端點(diǎn)
- 其中 /health 端點(diǎn)能夠全面你檢查應(yīng)用監(jiān)控狀態(tài)
快速入門
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
- 控制臺(tái)可看到 Actuator 為我們添加了許多端點(diǎn)
2017-12-22 14:13:14.781 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2017-12-22 14:13:14.781 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env || /env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-12-22 14:13:14.782 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto 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
2017-12-22 14:13:14.783 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-12-22 14:13:14.784 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
2017-12-22 14:13:14.784 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-12-22 14:13:14.785 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/features || /features.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-12-22 14:13:14.785 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-12-22 14:13:14.786 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/auditevents || /auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.boot.actuate.endpoint.mvc.AuditEventsMvcEndpoint.findByPrincipalAndAfterAndType(java.lang.String,java.util.Date,java.lang.String)
2017-12-22 14:13:14.786 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-12-22 14:13:14.787 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/archaius || /archaius.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-12-22 14:13:14.787 INFO 9441 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.value(java.util.Map<java.lang.String, java.lang.String>)
- 比如訪問 /health 端點(diǎn)锁保,可以獲得如下的應(yīng)用健康信息
{"description":"Composite Discovery Client","status":"UP"}
常用端點(diǎn)
- 某些端點(diǎn)屬于敏感信息,需要關(guān)閉權(quán)限認(rèn)證才能查看 management.security.enabled=false
URL |
描述 |
/autoconfig |
該端點(diǎn)用于獲取應(yīng)用自動(dòng)化配置報(bào)告叛买,幫助我們方便的找到自動(dòng)化配置為什么沒有生效 |
/beans |
描述上下文每個(gè) bean 的情況,包括 Java 類型已經(jīng)注入它的 bean蹋订,作用域等信息 |
/enc |
應(yīng)用程序可用的所有環(huán)境屬性列表率挣,無論這些屬性是否用到,其中包括環(huán)境變量露戒、JVM 屬性椒功、命令行參數(shù),以及配置文件 |
/configprops |
獲取屬性如何進(jìn)行設(shè)置(注入或其它方式) |
/mappings |
羅列出應(yīng)用程序的全部接口 |
/metrics |
顯示應(yīng)用程序內(nèi)存情況智什、線程池动漾、JVM等信息 |
/trace |
返回HTTP跟蹤信息,保留最近 100 條請(qǐng)求荠锭,包括請(qǐng)求的方法旱眯、路徑等詳細(xì)信息 |
/info |
顯示應(yīng)用的信息 |
/health |
顯示應(yīng)用的監(jiān)控信息 |
/dump |
顯示程序運(yùn)行中的線程信息 |
/shutdown |
通過該端點(diǎn)關(guān)閉應(yīng)用程序的遠(yuǎn)程操作,需要在配置文件里開啟 endpoints.shutdown.enabled=true |
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者