日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringBoot入门到精通_第5篇 _SpringBoot Actuator监控

發(fā)布時間:2024/9/27 javascript 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringBoot入门到精通_第5篇 _SpringBoot Actuator监控 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

接上一篇:SpringBoot入門到精通_第4篇 _開發(fā)三板斧
https://blog.csdn.net/weixin_40816738/article/details/101097161

文章目錄

  • 一、 SpringBoot Actuator 概念
    • 1. 是什么?
    • 2. 如何整合SpringBoot Actuator?
  • 二、 SpringBoot Actuator 實戰(zhàn)
    • 2.1. 監(jiān)控導(dǎo)航端點
    • 2.2. 默認端點
    • 2.3. 常用端點一覽表:
      • 2.3.1 健康檢查端點:
      • 2.3.2 應(yīng)用描述端點:
      • 2.3.2 激活所有的端點
      • 2.3.3 配置屬性端點
      • 2.3.4 度量指標端點
      • 2.3.5 查看jvm的內(nèi)存端點
      • 2.3.5 查看jvm的線程狀態(tài)端點
      • 2.3.6 根據(jù)需求激活某個端點

一、 SpringBoot Actuator 概念

1. 是什么?

  • SpringBoot Actuator是SpringBoot 里面非常重要的一個組件,他為我們的應(yīng)用提供了強大的監(jiān)控能力。
    現(xiàn)在的應(yīng)用越來越復(fù)雜了,線上往往需要借助一些監(jiān)控工具,快速的定位問題。

2. 如何整合SpringBoot Actuator?

  • 第一步:添加依賴
<!--監(jiān)控--> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId> </dependency>
  • 第二步:啟動類加注解(暫時不需要)
  • 第三步:寫配置(暫時不需要)

到此,整合SpringBoot Actuator完成了!!!

二、 SpringBoot Actuator 實戰(zhàn)





pom.xml依賴

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>

application.yml

#actuator監(jiān)控 # 暴露原則 # never :不暴露 # always :暴露 management:endpoint:health:show-details: always

2.1. 監(jiān)控導(dǎo)航端點

瀏覽器訪問
SpringBoot的導(dǎo)航端點:http://localhost:8080/actuator

2.2. 默認端點

  • 默認端點暴露health和info端點

2.3. 常用端點一覽表:

端點(SpringBoot2.x對照)描述http方法端點(SpringBoot1.x對照)
conditions顯示自動配置信息GETautoconfig
beans顯示應(yīng)用程序上下文所有的SpringbeanGETbeans
configprops顯示@ConfigurationProperties的配置屬性列表GETconfigprops
threaddump顯示縣城活動的快照GETdump
env顯示環(huán)境變量,包括系統(tǒng)環(huán)境變量以及應(yīng)用環(huán)境變量GETenv
health顯示應(yīng)用程序的健康指標,值由HealthIndicator的實現(xiàn)類提供;結(jié)果有UP、DOWNOUT_OF_SERVICE、UNKOWN; 如需查看詳情,需要配置management.endpoint.health. show-detailsGEThealth
heapdump堆dumpGETheapdump
info小時應(yīng)用的信息,可食用info.*屬性自定義info端點公開的數(shù)據(jù)GETinfo
loggersGET:顯示日志級別 POST:動態(tài)修改日志級別GET/POSTloggers
mappings顯示所有URL的路徑GETmappings
metrics顯示應(yīng)用度量指標信息GETmetrics

2.3.1 健康檢查端點:

http://localhost:8080/actuator/health

# /health # 作用:健康檢查 # status 取值: #UP:正常 #DOWN:遇到問題,不正常 #OUT_OF_SERVICE:資源未在使用,或者不該去使用 #UNKNOWN: 不知道

2.3.2 應(yīng)用描述端點:

http://localhost:8080/actuator/info

2.3.2 激活所有的端點

#激活導(dǎo)航端點actuator下面的所有的端點

#actuator監(jiān)控 # 暴露原則 # never :不暴露 # always :暴露 #激活所有的actuator端點 management:endpoints:web:exposure:include: "*"endpoint:health:show-details: always#描述應(yīng)用 端點info key value形式 info.app-name: springboot-actuator info.author: gblfy info.email: gblfy@email.com

2.3.3 配置屬性端點

/actuator/configprops端點:
表示:應(yīng)用當前的配置屬性
應(yīng)用場景:在項目中配置了某個屬性,可以通過此端點查看配置是否生效
http://localhost:8080/actuator/configprops

2.3.4 度量指標端點

http://localhost:8080/actuator/metrics
具體查看,在后面拼接即可

2.3.5 查看jvm的內(nèi)存端點

http://localhost:8080/actuator/metrics/jvm.memory.max

2.3.5 查看jvm的線程狀態(tài)端點

http://localhost:8080/actuator/metrics/jvm.threads.states

2.3.6 根據(jù)需求激活某個端點

比如說想激活/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

總結(jié)

以上是生活随笔為你收集整理的SpringBoot入门到精通_第5篇 _SpringBoot Actuator监控的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。