javascript
SpringBoot入门到精通_第5篇 _SpringBoot Actuator监控
接上一篇:SpringBoot入門到精通_第4篇 _開發三板斧
https://blog.csdn.net/weixin_40816738/article/details/101097161
文章目錄
- 一、 SpringBoot Actuator 概念
- 1. 是什么?
- 2. 如何整合SpringBoot Actuator?
- 二、 SpringBoot Actuator 實戰
- 2.1. 監控導航端點
- 2.2. 默認端點
- 2.3. 常用端點一覽表:
- 2.3.1 健康檢查端點:
- 2.3.2 應用描述端點:
- 2.3.2 激活所有的端點
- 2.3.3 配置屬性端點
- 2.3.4 度量指標端點
- 2.3.5 查看jvm的內存端點
- 2.3.5 查看jvm的線程狀態端點
- 2.3.6 根據需求激活某個端點
一、 SpringBoot Actuator 概念
1. 是什么?
- SpringBoot Actuator是SpringBoot 里面非常重要的一個組件,他為我們的應用提供了強大的監控能力。
現在的應用越來越復雜了,線上往往需要借助一些監控工具,快速的定位問題。
2. 如何整合SpringBoot Actuator?
- 第一步:添加依賴
- 第二步:啟動類加注解(暫時不需要)
- 第三步:寫配置(暫時不需要)
到此,整合SpringBoot Actuator完成了!!!
二、 SpringBoot Actuator 實戰
pom.xml依賴
application.yml
#actuator監控 # 暴露原則 # never :不暴露 # always :暴露 management:endpoint:health:show-details: always2.1. 監控導航端點
瀏覽器訪問
SpringBoot的導航端點:http://localhost:8080/actuator
2.2. 默認端點
- 默認端點暴露health和info端點
2.3. 常用端點一覽表:
| conditions | 顯示自動配置信息 | GET | autoconfig |
| beans | 顯示應用程序上下文所有的Springbean | GET | beans |
| configprops | 顯示@ConfigurationProperties的配置屬性列表 | GET | configprops |
| threaddump | 顯示縣城活動的快照 | GET | dump |
| env | 顯示環境變量,包括系統環境變量以及應用環境變量 | GET | env |
| health | 顯示應用程序的健康指標,值由HealthIndicator的實現類提供;結果有UP、DOWNOUT_OF_SERVICE、UNKOWN; 如需查看詳情,需要配置management.endpoint.health. show-details | GET | health |
| heapdump | 堆dump | GET | heapdump |
| info | 小時應用的信息,可食用info.*屬性自定義info端點公開的數據 | GET | info |
| loggers | GET:顯示日志級別 POST:動態修改日志級別 | GET/POST | loggers |
| mappings | 顯示所有URL的路徑 | GET | mappings |
| metrics | 顯示應用度量指標信息 | GET | metrics |
2.3.1 健康檢查端點:
http://localhost:8080/actuator/health
# /health # 作用:健康檢查 # status 取值: #UP:正常 #DOWN:遇到問題,不正常 #OUT_OF_SERVICE:資源未在使用,或者不該去使用 #UNKNOWN: 不知道2.3.2 應用描述端點:
http://localhost:8080/actuator/info
2.3.2 激活所有的端點
#激活導航端點actuator下面的所有的端點
#actuator監控 # 暴露原則 # never :不暴露 # always :暴露 #激活所有的actuator端點 management:endpoints:web:exposure:include: "*"endpoint:health:show-details: always#描述應用 端點info key value形式 info.app-name: springboot-actuator info.author: gblfy info.email: gblfy@email.com2.3.3 配置屬性端點
/actuator/configprops端點:
表示:應用當前的配置屬性
應用場景:在項目中配置了某個屬性,可以通過此端點查看配置是否生效
http://localhost:8080/actuator/configprops
2.3.4 度量指標端點
http://localhost:8080/actuator/metrics
具體查看,在后面拼接即可
2.3.5 查看jvm的內存端點
http://localhost:8080/actuator/metrics/jvm.memory.max
2.3.5 查看jvm的線程狀態端點
http://localhost:8080/actuator/metrics/jvm.threads.states
2.3.6 根據需求激活某個端點
比如說想激活/actuator/health和/actuator/metrics端點,該怎么做?
management:endpoints:web:exposure:include: health,metricsendpoint:health:show-details: always下一篇:
SpringBoot入門到精通_第6篇 _必知必會
https://blog.csdn.net/weixin_40816738/article/details/101100029
總結
以上是生活随笔為你收集整理的SpringBoot入门到精通_第5篇 _SpringBoot Actuator监控的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springboot pom 依赖
- 下一篇: windows下载、安装运行redis