🔥
Caster 開發日誌
  • Java
    • JVM Performance Tool
      • Java Debug Wire Protocol (JDWP) 的詳細介紹
      • JConsole 詳細介紹
    • Spring Boot
      • Spring Security
      • Spring Boot Admin
      • Spring Event
      • Spring AOP
      • Spring Boot JUnit 5
      • Apache Dubbo
    • Reflect 應用
    • ELK + F 建構
    • Socket.IO
    • OCR - 光學字元辨識
    • 讀取JAR resource文件
    • LocalTime & MySQL時間精度
    • Gradle multi module
    • MyBatis-Plus
    • Java Date operation
    • Java IP to Long
    • Apache Commons lang3 應用
      • Function 應用
    • Cloud Platform
      • Amazon S3
        • SDK V1
          • Bucket
        • SDK V2
          • Bucket
      • Google Cloud Platform
      • Azure Cloud
        • Storage
      • OVHcloud
        • Config
    • SSL/TLS工具
    • Util 工具
      • Jackson Json工具
      • Charles應用
      • JMeter – Performing Distributed Load Testing with Docker
    • Redis
      • Stream
      • Redisson 分布式鎖機制
      • Create Redis Cluster Using Docker
      • List Operations
    • Java 8
      • method & constructor Reference
      • CompletableFuture
      • FunctionInterface
      • Stream 應用
      • 繁簡轉換 - 簡易調整
    • MySQL
      • 建立測試用 流水號Table
      • SQL 效能調校 - Explain
      • SQL 效能調校 - Partition
      • 排程 - Event
    • Apache ShardingSphere
  • Kubernetes
    • 初入江湖(K8S)
    • 零中斷服務滾動更新
    • Kubernetes DNS
    • Ingress & Ingress Controller 教學
    • Ingress TLS Easy setup
  • 指令集
  • Telegram
  • SourceTree
    • 踩坑紀錄(ㄧ) - Git Flow
    • 踩坑紀錄(二) - 修改檔名
  • 專案統計
    • Robot
    • Recharge
  • GitHub
    • Actions
  • GitLab
    • 介紹 GitLab
    • 使用 Docker 自架 GitLab
    • 簡介 GitLab CI/CD
      • GitLab Runner 詳細介紹與設定方式
Powered by GitBook
On this page
  • 第一部分 Spring Boot Admin 簡介
  • 第二部分 簡單實作
  • Admin Server
  • Client Server
  • 實作結果
  1. Java
  2. Spring Boot

Spring Boot Admin

Spring Boot Admin用來管理和監控Spring Boot應用程式

第一部分 Spring Boot Admin 簡介

SpringBoot應用可以通過Actuator來暴露應用運行過程中的各項指標,Spring Boot Admin通過這些指標來監控SpringBoot應用,然後通過圖形化界面呈現出來。Spring Boot Admin不僅可以監控單體應用,還可以和Spring Cloud的注冊中心相結合來監控微服務應用。

對於我們來說,我們可以通過 Spring Boot Admin 瀏覽所有被監控的 Spring Boot 項目,詳細的 Health 信息、內存信息、JVM 系統和環境屬性、垃圾回收信息等。

Spring Boot Admin 可以提供應用的以下監控信息等:

  • 監控應用運行過程中的概覽資訊

  • 度量標信息,比如JVM、Tomcat及進程資訊

  • 查看環境變數,比如系統屬性、系統環境變量以及應用配置資訊

  • 查看所有創建的Bean資訊

  • 查看應用中的所有配置資訊

  • 查看應用運行日志資訊

  • 查看HTTP跟蹤資訊

Spring Boot Admin 由兩種角色組成:一種是 Server 端;一種是 Client 端,即要被監控的應用。

第二部分 簡單實作

Admin Server

引入Library

implementation group: 'de.codecentric', name: 'spring-boot-admin-server', version: '2.3.1'

啟用 Admin Server

@EnableAdminServer
@SpringBootApplication
public class MonitorAdminApplication {
    public static void main(String[] args) {
        SpringApplication.run(MonitorAdminApplication.class, args);
    }
}

application.yml 設置

spring:
  security:
    user:
      name: admin
      password: 1qaz2wsx
  application:
    name: monitorAdmin

server:
  port: 80

Client Server

引入Library

implementation group: 'de.codecentric', name: 'spring-boot-admin-starter-client', version: '2.3.1'

啟動程式

@SpringBootApplication
@EnableScheduling
@EnableTransactionManagement
public class ManualRechargeApplicationRestApi {

    public static void main(String[] args) {
        SpringApplication.run(ManualRechargeApplicationRestApi.class, args);
    }

    // 新版Default沒提供Http Trace 資料需自行複寫.
    @Bean
    public HttpTraceRepository httpTraceRepository() {
        return new InMemoryHttpTraceRepository();
    }
}

application.yml 設置

spring:
  application:
    name: manualRecharge
  boot:
    admin:
      client:
        username: admin
        password: 1qaz2wsx
        url: http://localhost:80 #配置admin-server地址
        instance:
          service-base-url: http://localhost:8080
server:
  port: 8080

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
    shutdown:
      enabled: true
  health:
    redis:
      enabled: false

實作結果

參考網站:

PreviousSpring SecurityNextSpring Event

Last updated 1 year ago

https://cloud.tencent.com/developer/article/1752851