spring cloud微服務快速教程之(六) 應用監控 spring boot admin


0-前言

  當我們發布了微服務后,我們希望對各個應用的各個運行狀況進行一個監控;這個時候spring boot admin,就出場了;

  spring boot admin:是一個監控和管理spring boot 應用的開源監控組件, 它能夠對Actuator 中的信息進行界面化的展示,也可以監控所有 Spring Boot 應用的健康狀況,提供實時警報功能。

 

一、集成spring boot admin

1、創建server端:

1.1、創建monitor模塊,添加依賴:

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

1.2、啟動類增加 @EnableAdminServer 注解

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

}

服務端完成

2、客戶端(需要監控的應用端):

2.1、添加依賴:

        <!-- 集成Admimn監控-->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.0.5</version>
        </dependency>

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

 

2.2、配置文件中增加配置:

spring:
  application:
    name: user

  boot:
    admin:
      client:
        url: http://localhost:8771

management:
  endpoints:
    web:
      exposure:
        include: "*"

完成

 

3、運行測試

  依次啟動各相關項目,打開monitor地址,可以看到,對所添加的監控項目已經進行了各種監控,很方便我們查看運行狀況,內容包括:

顯示應用程序的監控狀態、應用程序上下線監控、查看 JVM,線程信息、可視化的查看日志以及下載日志文件、動態切換日志級別、Http 請求信息跟蹤等;可以自己去深入了解各監控項;

 

 

 

 

 

 

  GITdemo地址:https://github.com/anson-yang/springclouddemo

 


免責聲明!

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



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