LoginSignup
1

More than 3 years have passed since last update.

Spring Boot > Actuator

Posted at

Actuatorでアプリケーションをモニタリング

build.gradle.kt > dependenciesに以下を追加

dependencies {
...
  implementation('org.springframework.boot:spring-boot-starter-actuator')
...
}

これで実行するだけでモニタリング可能になる

endpoints 一覧

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

参考

Spring Boot Actuator Web API Documentation

ことりんと一緒 Springもね - 5. Actuator - Qiita

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1