Actuatorでアプリケーションをモニタリング
build.gradle.kt > dependenciesに以下を追加
dependencies {
...
implementation('org.springframework.boot:spring-boot-starter-actuator')
...
}
これで実行するだけでモニタリング可能になる
actuatorの設定を変更するにはapplication.ymlに追記する
以下のようにbaseのPathを変更するには
http://localhost:8080/actuator/health
↓
http://localhost:8080/other/health
management > endpoints > webに追加する。
src/main/resources/application.yml
management:
endpoints:
web:
base-path: /other # → Default is /actuator
エンドポイントの公開
デフォルトで有効になっているエンドポイントは以下の2つ
/health
/info
management > endpoints > exposure > include に追加する。
include: "*"
または
include: エンドポイント名, エンドポイント名
ex. include: beans, env
以下のような感じ
src/main/resources/application.yml
spring:
application:
name: Message API
server:
port: 8080
management:
endpoints:
web:
exposure:
include: health, info, beans, env, scheduledtasks
base-path: /other # → Default is /actuator