POM依存関係を追加します:
<! - spring-boot-monitoring-> <dependency> groupid> org.springframework.boot </groupid> <artifactid> spring-boot-starter-actuator </artifactid> </depence> <dependency> <groupid> org.springframework.boot </groupid> <artifactid> spring-boot-starter-web </artifactid> </dependency>
Application.yml(指定されていない場合はサーバーと同じポート)で監視されているHTTPポートを指定します。特定のチェックを削除するように指定します(Health.mailを監視しないなど):
サーバー:ポート:8083管理:ポート:8083セキュリティ:有効:false#
エンドポイントを監視および管理します
| エンドポイント名 | 説明する |
|---|---|
| autoconfig | すべての自動構成情報(positivematches:実行、negativematchesがコンポーネントを実行していない) |
| 監査 | 監査イベント |
| 豆 | すべてのBean情報 |
| configProps | すべての構成プロパティ |
| ごみ | スレッドステータス情報 |
| env | 現在の環境情報 |
| 健康 | 健康状態を適用します |
| 情報 | 現在のアプリケーション情報 |
| メトリック | アプリケーションのさまざまな指標 |
| マッピング | @RequestMappingマップパスを適用します |
| シャットダウン | 現在のアプリケーションを閉じます(デフォルトで閉じます) |
| トレース | トラッキング情報(最新のHTTPリクエスト) |
| heapdump | メモリスナップショットをダウンロードします |
http:// localhost:8083/info infoを読む。*構成ファイルapplication.propertiesのプロパティ
infopropertiesを読んでください
Application.Properties:
info.app.version = v1.2.0info.app.name = abc
git.properties情報をgitpropertiesで入手してください
info.app.version = v1.2.0info.app.name = abc#remotely close and enable endpoints.shutdown.enabled = true#access:http:// localhost:8083/shutdown close closeサービス
メトリック
{mem:573549、//メモリサイズmem.free:388198、//メモリ残りサイズプロセッサ://プロセッサ数instime.uptime:338426、uptime:345091、systemload.average:-1、heap.committed:489984、heap.init:131072、heap:131072、heap. 1842688、nonheap.committed:85056、nonheap.init:2496、nonheap.used:83566、nonheap:0、threads.peak:46、threads.daemon:36、totalStarted:72、threads:39、// swrew classes:12109、loaded:loaded:12109、loaded:loaded:12109 //Unloaded class gc.ps_scavenge.count: 10,gc.ps_scavenge.time: 103,gc.ps_marksweep.count: 3,gc.ps_marksweep.time: 219,httpsessions.max: -1,httpsessions.active: 0,gauge.response.mappings: 3,gauge.response.autoconfig: 4、Gauge.response.trace:167、counter.status.200.マッピング:1、counter.status.200.autoconfig:2、counter.status.200.trace:1}}カスタム構成手順:
#close metrics function endpoints.metrics.enabled = false#enable shutdown remote shutdown endpoints.shutdown.shutdown.shutdown.enabled = true#set beansidendpoints.id = mybean#set beans path endpoints.beans.path =/bean Directory Management.Context-Path =/manage management.port = 8181
org.springframework.boot.actuate.healthパッケージには、Redishealthindicatorなどのすべての健康状態チェックが含まれています。
{status: "down"、// status diskspace:{status: "up"、total:395243941888、free:367246643200、threshold:10485760}、rabbit:{status: "down"、error: "org.springception.mqp.mqconnectexcection:拒否:connect "}、redis:{status:" up "、version:" 4.0.9 "}、db:{status:" up "、database:" mysql "、hello:1}}カスタムヘルス
•カスタムヘルスステータスインジケーター
•1。 HealthIndicatorインターフェイスを実装するインジケータを作成します
•2。インジケータxxxxhealthindicatorの名前
•3。コンテナに追加します
org.springframework.boot.actuate.health.health; Import org.springframework.boot.actuate.health.healthindicator; Import org.springframework.stereotype.component; @componentpublic class myapphealthindicator Implements emplentic method // health.up()。build()は、Health Return Health.down()を表します。 }}
要約します
上記は、編集者が紹介したSpring Boot Starter Actuator(Health Monitoring)の構成と使用のチュートリアルです。それがあなたに役立つことを願っています。ご質問がある場合は、メッセージを残してください。編集者は時間内に返信します。 wulin.comのウェブサイトへのご支援ありがとうございます!