Springboot - 監控模塊Admin(springboot-satrter-admin)未生效及解決辦法


                      

    Spring Boot Admin是一個開源社區項目,用於管理和監控SpringBoot應用程序。 應用程序作為Spring Boot Admin Client向為Spring Boot Admin Server注冊(通過HTTP)或使用SpringCloud注冊中心(例如Eureka,Consul)發現。 UI是的AngularJs應用程序,展示Spring Boot Admin Client的Actuator端點上的一些監控。

    強大之處是毋庸置疑的,但是在我本地出現了一次‘禿然’ 失效的問題,也是讓人啼笑皆非。。。

    問題出現在一次本地依賴jar包整理之后,使用IDEA查看所依賴的第三方庫的時候,發現springboot-starter-web所支持的Restfull已經被我們改成了MQTT的方式通訊,那就意味這是否可以將這個web包剔除掉嗎;當然,剔除掉后,對項目的編譯、打包、啟動、運行都是毫無影響的,但是偏偏Spring Boot Admin Server再也收不到這個項目的監控消息了,而且這個項目也不報異常啥的。。。

    沒辦法,只好在查一查這個Spring Boot Admin到底是怎樣用的,果然讓我們查到了問題排查的大致原因;

    再結合項目中的springboot-starter-admin失效的時間跟代碼提交時間對比,基本上是吻合的;

    加上spring-boot-starter-web之后,問題就解決了,應該是Admin是通過發送restful請求到項目的HTTP接口,來調用需要監控的各個性能指標的,這些功能都是需要依賴web包的,移除后就不能正常的提供這些接口服務,那Admin Server 端也就無法獲取項目的信息,雖然項目也沒有異常出現。。。

    完整配置如下:POM依賴 + application.yml配置

              <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
			<version>${springboot.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<version>${springboot.version}</version>
		</dependency>
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId>spring-boot-admin-starter-client</artifactId>
			<version>2.1.6</version>
		</dependency>
spring:
    boot:
        admin:
            client:
                url: http://127.0.0.1:8866
                instance:
                    name: http-server-xxxx
management:
    endpoints:
        web:
            exposure:
                include: '*'
    endpoint:
        health:
            show-details: always
        shutdown:
            enabled: true
    security:
        enabled: false

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM