springboot 監控 Actuator

springboot 提供了對項目的監控功能。

1.首先添加依賴包

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
<dependency>
     <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
   <version>2.1.3.RELEASE</version>
</dependency>

2.瀏覽器訪問

http://127.0.0.1:8080/actuator/health  訪問項目監控需要加前綴 /actuator

https://img2018.cnblogs.com/blog/1555009/201904/1555009-20190412164050739-1506764825.png https://img2018.cnblogs.com/blog/1555009/201904/1555009-20190412164121233-338226551.png

因爲actuator默認只支持端點 /health/info 所以訪問 /env 會出現404頁面。

3.配置端點

application.properties中配置端點,

暴露部分端點

management.endpoints.web.exposure.include=info,health,beans,env

暴露所有端點

management.endpoints.web.exposure.include=*

不暴露beans端點

management.endpoints.web.exposure.exclude=beans

在上述配置中,首先使用 management.endpoints.web.exposure.include 暴露所有的端點,接着使用management.endpoints .web.exposure.exclud 排除 en 端點,這樣就能夠暴露除 env 外的所有 ctuator
端點了。

4.端點說明

 

5.端點其他配置

# Actuator 管理端口
management.server.port=8000
#暴露 有端
management.endpoints.web.exposure.include =女
#默認情況下 有端點都不啓用,此時需要按需啓用端點
management.endpoints.enabled-by-default=false 
#啓用端點 info
management.endpoint.info.enabled=true 

#啓用端點 beans
management.endpoint.beans.enabled=true 

#啓用端點 configprops 
management.endpoint.configprops.enabled=true 

#啓用端點 env
management.endpont.env.enabled=true

#啓用端點 health
management.endpoint.health.enabled=true 

#啓用端點 mappings
management.endpont.mappings.enabed=true

#啓用端點 shutdown
management.endpoint.shutdown.enabled=true 
# Actuator
端點前綴
management.endpoints.web.base -path=/manage 
#將原來的 mappings 端點的請求路徑修改爲 urlMappings
management.endpoints.web.path-mapping.mappings=request_mappings
# Spring MVC
視圖解析器配置
spring.mvc.view.prefix=/WEB-INF/jsp/ 
spring.mvc.view.suffix=.Jsp

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章