springCloud--admin監控使用

Admin監控應用

Spring Boot提供的監控接口,例如:/health、/info等等,實際上除了以前提到的信息,還有其餘信息業須要監控:當前處於活躍狀態的會話數量、當前應用的併發數、延遲以及其餘度量信息。下面咱們來了解如何使用spring-boot-admin來監控咱們的系統。php

admin-server-ui

pom.xml配置:java

  1.  
    <parent>
  2.  
    <groupId>org.springframework.boot</groupId>
  3.  
    <artifactId>spring-boot-starter-parent</artifactId>
  4.  
    <version>1.4.3.RELEASE</version>
  5.  
    <relativePath/>
  6.  
    </parent>
  7.  
    <dependencyManagement>
  8.  
    <dependencies>
  9.  
    <dependency>
  10.  
    <groupId>org.springframework.cloud</groupId>
  11.  
    <artifactId>spring-cloud-dependencies</artifactId>
  12.  
    <version>Camden.SR5</version>
  13.  
    <type>pom</type>
  14.  
    <scope>import</scope>
  15.  
    </dependency>
  16.  
    </dependencies>
  17.  
    </dependencyManagement>
  18.  
    <dependencies>
  19.  
    <dependency>
  20.  
    <groupId>org.springframework.cloud</groupId>
  21.  
    <artifactId>spring-cloud-starter-eureka</artifactId>
  22.  
    </dependency>
  23.  
    <dependency>
  24.  
    <groupId>de.codecentric</groupId>
  25.  
    <artifactId>spring-boot-admin-server</artifactId>
  26.  
    <version>1.4.5</version>
  27.  
    </dependency>
  28.  
    <dependency>
  29.  
    <groupId>de.codecentric</groupId>
  30.  
    <artifactId>spring-boot-admin-server-ui</artifactId>
  31.  
    <version>1.4.5</version>
  32.  
    </dependency>
  33.  
    </dependencies>
  • 注意版本號(1.5.2+1.5.7)

application.properties配置:spring

  1.  
    spring .application.name=admin-ui
  2.  
    info .version=@project.version@
  3.  
    server .port=8080
  4.  
     
  5.  
    eureka .client.serviceUrl.defaultZone=http://localhost:8888/eureka/

java代碼:安全

  1.  
    @SpringBootApplication
  2.  
    @EnableDiscoveryClient
  3.  
    @EnableAdminServer
  4.  
    public class AdminApplication {
  5.  
     
  6.  
    public static void main(String[] args) {
  7.  
    SpringApplication.run(AdminApplication.class, args);
  8.  
    }
  9.  
    }

logback-spring.xml配置:併發

  1.  
    <?xml version="1.0" encoding="UTF-8"?>
  2.  
    <configuration>
  3.  
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
  4.  
    <jmxConfigurator/>
  5.  
    </configuration>

添加其餘項目被監控

在被監控的服務pom.xml中增長:app

  1.  
    <!--
  2.  
    spring-boot-admin-starter-client中包含的spring-boot-starter-actuator用於收集服務信息
  3.  
    <dependency>
  4.  
    <groupId>org.springframework.boot</groupId>
  5.  
    <artifactId>spring-boot-starter-actuator</artifactId>
  6.  
    </dependency>
  7.  
    -->
  8.  
    <dependency>
  9.  
    <groupId>de.codecentric</groupId>
  10.  
    <artifactId>spring-boot-admin-starter-client</artifactId>
  11.  
    <version>1.4.5</version>
  12.  
    </dependency>

application.properties增長:spring-boot

  1.  
    # 關閉安全訪問
  2.  
    management.security.enabled= false
  3.  
     
  4.  
    # 若是被監控的服務沒有註冊到服務中心,須要增長admin的地址
  5.  
    # spring.boot.admin.url=http://localhost:8888

 

增長logback-spring.xml:ui

  1.  
    <?xml version="1.0" encoding="UTF-8"?>
  2.  
    <configuration>
  3.  
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
  4.  
    <jmxConfigurator/>
  5.  
    </configuration>
  6.  
     
  7.  
     

 

  • 主控界面:

 

  • 單個服務的詳情頁面,其它再也不贅述.

 轉自:https://blog.csdn.net/u014320421/article/details/79708622url

相關文章
相關標籤/搜索