【SpringBoot】 監控工具 Actuator
參考: https://kucw.github.io/blog/2020/7/spring-actuator/
官方文件: https://docs.spring.io/spring-boot/docs/current/actuator-api/htmlsingle/
Actuator 提供的所有 endpoint
此處使用的是 SpringBoot 2.2.8 版本,Spring 官方文件
| HTTP方法 | Endpoint | 描述 |
|---|---|---|
| GET | /actuator | 查看有哪些 Actuator endpoint 是開放的 |
| GET | /actuator/auditevent | 查看 audit 的事件,例如認證進入、訂單失敗,需要搭配 Spring security 使用,sample code |
| GET | /actuator/beans | 查看運行當下裡面全部的 bean,以及他們的關係 |
| GET | /actuator/conditions | 查看自動配置的結果,記錄哪些自動配置條件通過了,哪些沒通過 |
| GET | /actuator/configprops | 查看注入帶有 @ConfigurationProperties 類的 properties 值為何(包含默認值) |
| GET | /actuator/env (常用) | 查看全部環境屬性,可以看到 SpringBoot 載入了哪些 properties,以及這些 properties 的值(但是會自動*掉帶有 key、password、secret 等關鍵字的 properties 的值,保護安全資訊,超聰明!) |
| GET | /actuator/flyway | 查看 flyway DB 的 migration 資訊 |
| GET | /actuator/health (常用) | 查看當前 SpringBoot 運行的健康指標,值由 HealthIndicator 的實現類提供(所以可以自定義一些健康指標資訊,加到這裡面) |
| GET | /actuator/heapdump | 取得 JVM 當下的 heap dump,會下載一個檔案 |
| GET | /actuator/info | 查看 properties 中 info 開頭的屬性的值,沒啥用 |
| GET | /actuator/mappings | 查看全部的 endpoint(包含 Actuator 的),以及他們和 Controller 的關係 |
| GET | /actuator/metrics | 查看有哪些指標可以看(ex: jvm.memory.max、system.cpu.usage),要再使用/actuator/metrics/{metric.name}分別查看各指標的詳細資訊 |
| GET | /actuator/scheduledtasks | 查看定時任務的資訊 |
| POST | /actuator/shutdown | 唯一一個需要 POST 請求的 endpoint,關閉這個 SpringBoot 程式 |
常用命令
curl -X GET 'http://192.168.77.185:8080/actuator/mappings'