SpringBoot學習(二十二)之使用監控管理

Spring Boot Admin 2.0新特性
Spring Boot Admin 2.0 變化還是挺多的,具體參考 官網說明,這裏列幾條主要的:
使用Vue.js重寫了UI界面,漂亮得不像實力派
直接集成了基於 spring security 的認證,無需引入第三方模塊
加入 session endpoint 的監控支持
等等…
下面就實際試驗來操作感受一下!

搭建 Spring Boot Admin Server
創建一個 SpringBoot 2.0.3 RELEASE 工程並添加依賴

<dependencies>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server-ui</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

應用主類添加註解

@SpringBootApplication
@EnableAdminServer
public class SbaServer20Application {

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

啓動 Spring Boot Admin Server
瀏覽器打開 localhost:8080,就可以看到小清新的頁面了
file
可以看到這個 UI 的變化和 1.5.X 時代的差距還是蠻大的,此時被監控的應用數目還爲0。
接下來我們就來創建一個待監控的Spring Boot 2.0示例。

創建 Spring Boot Admin Client
此處我們依然創建一個 Spring Boot 2.0.3.RELEASE 的應用,然後加入到Spring Boot Admin之中進行監控
pom.xml中添加依賴

 <dependencies>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

編輯配置文件

server.port=8081
spring.application.name=Spring Boot Client
spring.boot.admin.client.url=http://localhost:8080
management.endpoints.web.exposure.include=*

啓動 Spring Boot Admin Client 應用
此時 Spring Boot Admin的頁面上應用上線的消息推送過來了:
在這裏插入圖片描述
實際實驗
被監控應用上線之後,我們進入 Spring Boot Admin頁面鼓搗看看
Wallboard 有點小清新
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-QO0TTVuJ-1574927838167)(http://note.youdao.com/yws/res/5202/WEBRESOURCEa4a2fc267f7339c032ce2099b2680622)]
Applications 概覽
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-OBokkj1m-1574927838168)(http://note.youdao.com/yws/res/5205/WEBRESOURCE35ed513f8c6299e89ce7d02047bd08d9)]
Metrics
file
Environment
file
JMX
file
Threads
file
Http Traces
file

發佈了118 篇原創文章 · 獲贊 91 · 訪問量 18萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章