av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

SpringBoot配置Actuator組件,實現系統監控

瀏覽:6日期:2023-03-03 15:17:41
目錄一、Actuator簡介二、與SpringBoot2.0整合 1、核心依賴Jar包2、Yml配置文件三、監控接口詳解 1、Info接口2、Health接口3、Beans接口4、Conditions接口5、HeapDump接口6、Mappings接口7、ThreadDump接口8、ShutDown接口四、源代碼地址 一、Actuator簡介

監控分類

Actuator 提供Rest接口,展示監控信息。 接口分為三大類: 應用配置類:獲取應用程序中加載的應用配置、環境變量、自動化配置報告等與SpringBoot應用相關的配置類信息。 度量指標類:獲取應用程序運行過程中用于監控的度量指標,比如:內存信息、線程池信息、HTTP請求統計等。 操作控制類:提供了對應用的關閉等操作類功能。二、與SpringBoot2.0整合 1、核心依賴Jar包

<!-- 監控依賴 --><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId></dependency>2、Yml配置文件

# 端口server: port: 8016spring: application: # 應用名稱 name: node16-boot-actuatormanagement: endpoints: web: exposure:# 打開所有的監控點include: '*' # 自定義監控路徑 monitor # 默認值:http://localhost:8016/actuator/* # 配置后:http://localhost:8016/monitor/* base-path: /monitor endpoint: health: show-details: always shutdown: # 通過指定接口關閉 SpringBoot enabled: true # 可以自定義端口 # server: # port: 8089# 描述項目基礎信息info: app: name: node16-boot-actuator port: 8016 version: 1.0.0 author: cicada三、監控接口詳解 1、Info接口

Yml文件中配置的項目基礎信息

路徑:http://localhost:8016/monitor/info輸出:{ 'app': {'name': 'node16-boot-actuator','port': 8016,'version': '1.0.0','author': 'cicada' }}2、Health接口

health 主要用來檢查應用的運行狀態

路徑:http://localhost:8016/monitor/health輸出:{ 'status': 'UP', 'details': {'diskSpace': { 'status': 'UP', 'details': {'total': 185496236032,'free': 140944084992,'threshold': 10485760 }} }}3、Beans接口

展示了 bean 的類型、單例多例、別名、類的全路徑、依賴Jar等內容。

路徑:http://localhost:8016/monitor/beans輸出:{ 'contexts': {'node16-boot-actuator': {'beans': { 'endpointCachingOperationInvokerAdvisor': {'aliases': [],'scope': 'singleton','type': 'org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvokerAdvisor','resource': 'class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.class]','dependencies': ['environment'] }} }}4、Conditions接口

查看配置在什么條件下有效,或者自動配置為什么無效。

路徑:http://localhost:8016/monitor/conditions輸出:{ 'contexts': {'node16-boot-actuator': { 'positiveMatches': {'AuditAutoConfiguration#auditListener': [{ 'condition': 'OnBeanCondition', 'message': '@ConditionalOnMissingBean'}], }}5、HeapDump接口

自動生成Jvm的堆轉儲文件HeapDump,可以使用監控工具 VisualVM 打開此文件查看內存快照。

路徑:http://localhost:8016/monitor/heapdump6、Mappings接口

描述 URI 路徑和控制器的映射關系

路徑:http://localhost:8016/monitor/mappings輸出:{ 'contexts': {'node16-boot-actuator': { 'mappings': {'dispatcherServlets': { 'dispatcherServlet': [ {'handler': 'Actuator web endpoint ’auditevents’','predicate': '{GET /monitor/auditevents || application/json]}','details': { 'handlerMethod': {'className': 'org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.Operat'name': 'handle','descriptor': '(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Map;)Ljava/lang/Object;' }, 'requestMappingConditions': {'consumes': [],'headers': [],'methods': ['GET'],'params': [],'patterns': ['/monitor/auditevents'],'produces': [{ 'mediaType': 'application/vnd.spring-boot.actuator.v2+json', 'negated': false}, { 'mediaType': 'application/json', 'negated': false}] }} } } }}7、ThreadDump接口

展示線程名、線程ID、是否等待鎖、線程的狀態、線程鎖等相關信息。

路徑:http://localhost:8016/monitor/threaddump輸出:{ 'threads': [{'threadName': 'DestroyJavaVM','threadId': 34,'blockedTime': -1,'blockedCount': 0,'waitedTime': -1,'waitedCount': 0,'lockName': null,'lockOwnerId': -1,'lockOwnerName': null,'inNative': false,'suspended': false,'threadState': 'RUNNABLE','stackTrace': [],'lockedMonitors': [],'lockedSynchronizers': [],'lockInfo': null } ]}8、ShutDown接口

優雅關閉 Spring Boot 應用,默認只支持POST請求。

路徑:http://localhost:8016/monitor/shutdown四、源代碼地址

GitHub地址:知了一笑https://github.com/cicadasmile/spring-boot-base碼云地址:知了一笑https://gitee.com/cicadasmile/spring-boot-base

以上就是SpringBoot配置Actuator組件,實現系統監控的詳細內容,更多關于SpringBoot配置Actuator的資料請關注好吧啦網其它相關文章!

標簽: Spring
主站蜘蛛池模板: 精品二区| 久久久久一区二区三区四区 | 欧美日韩激情 | 亚洲成人精品影院 | 久久亚洲精品国产精品紫薇 | 99久久久久久 | 国产露脸国语对白在线 | 国产精品一区二区三区久久 | 日韩欧美在线播放 | 97国产一区二区精品久久呦 | 国产一区亚洲 | 日韩在线视频免费观看 | 欧美成人久久 | 国产成人jvid在线播放 | 亚洲精品视频在线播放 | 欧美日韩精品中文字幕 | 精品自拍视频 | 日韩精品一区二区三区中文在线 | 欧美精品网 | 精品毛片 | 成人国产精品久久 | 日韩中文字幕免费在线观看 | 91精品中文字幕一区二区三区 | 免费黄色大片 | 国产免费视频在线 | 欧美色性| 日本网站在线看 | 中文字幕av网址 | 久久新| 欧美一区二区综合 | 国产一区影院 | 99精品国产一区二区三区 | 91精品国产高清一区二区三区 | 精品国产乱码久久久久久丨区2区 | 久久在看 | 欧美日韩不卡在线 | 欧美日韩a| 亚洲精品在线免费观看视频 | 久久久久久网 | 成人一区二区三区在线观看 | 久久综合狠狠综合久久 |