자바 웹 의 springboot 튜 토리 얼 의 31-Attuator 와 spring-boot-admin

4856 단어 JavaWebspringboot
restful api 를 통 해 정 보 를 보 는 것 이 너무 번 거 롭 고 직관 적 이지 않 으 며 효율 이 떨어진다.서비스 가 너무 많 을 때 너무 번 거 로 워 보이 기 때문에 모든 서 비 스 는 서로 다른 인 터 페 이 스 를 이용 하여 감시 정 보 를 조회 해 야 한다.
springboot 핵심 주석 참조:https://www.ctolib.com/topics-138637.html
SBA
SBA 전 칭 spring boot admin 은 spring boot 응용 프로그램 을 관리 하고 감시 하 는 오픈 소스 프로젝트 로 admin-server 와 admin-client 두 구성 요소 로 나 뉜 다.admin-server 는 actuator 터미널 데 이 터 를 수집 하여 spring-boot-admin-ui 에 나타 나 고 이미 알 고 있 는 터미널 은 거의 진행 채집 되 며 spring-boot-admin 을 통 해 로그 단 계 를 동적 으로 전환 하고 로 그 를 내 보 낼 수 있다.hepdump 내 보 내기,각종 지표 모니터링 등
spring boot admin 은 단일 서비스 모니터링 과 동시에 클 러 스 터 모니터링 방안 도 제공 하여 eureka,consul,zookeeper 등 등록 센터 의 방식 으로 다 중 서비스 모니터링 과 관 리 를 실현 하도록 지원 합 니 다.
홈 페이지 문서 참조:http://codecentric.github.io/spring-boot-admin/2.0.0/
Spring Boot 프로젝트 에서 Spring Boot Admin 은 서버 엔 드 로 서 모니터링 되 어야 할 다른 응용 프로그램 은 Client 엔 드 로 서
우선 다 중 모듈 springboot 프로젝트 를 만 듭 니 다.참고 하 십시오.https://blog.csdn.net/t2080305/article/details/81625433
1,server 모듈:
pom.xml
 


    de.codecentric
    spring-boot-admin-starter-server
    2.1.0


    org.springframework.boot
    spring-boot-starter-actuator


    org.springframework.boot
    spring-boot-starter-thymeleaf


    org.springframework.boot
    spring-boot-starter-web



    org.projectlombok
    lombok
    true


    org.springframework.boot
    spring-boot-starter-test
    test

프로필,application.properties:
 
server.port = 8000
spring.application.name=Spring Boot Admin Server
spring.boot.admin.url=http://localhost:${server.port}
spring.jackson.serialization.indent_output=true

시작 클래스:
 
package com.sba.server;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Created by Chen Xiang
 * Date: 2019/4/28
 * Proj: multisba
 */
@SpringBootApplication
@EnableAdminServer
@Slf4j
public class SbaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(SbaServerApplication.class, args);
    }
}

시작 하면 localhost:8000 을 통 해 서버 에 접근 할 수 있 습 니 다.
 
2,클 라 이언 트:
pom.xml
 

    de.codecentric
    spring-boot-admin-starter-client
    2.1.0


    org.springframework.boot
    spring-boot-starter-thymeleaf


    org.springframework.boot
    spring-boot-starter-web



    org.projectlombok
    lombok
    true


    org.springframework.boot
    spring-boot-starter-test
    test

프로필:
 
server.port=8001
spring.application.name=Admin Client
spring.boot.admin.client.url=http://localhost:8000  
management.endpoints.web.exposure.include=*
  • spring.boot.admin.client.url Admin 서버 주소 설정
  • management.endpoints.web.exposure.include=* 클 라 이언 트 Actuator 모니터링 을 엽 니 다

  • 시작 클래스:
     
    package com.sba.client;
    
    import lombok.extern.slf4j.Slf4j;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    /**
     * Created by Chen Xiang
     * Date: 2019/4/28
     * Proj: multisba
     */
    @SpringBootApplication
    @Slf4j
    public class SbaClientApplication {
        public static void main(String[] args) {
            SpringApplication.run(SbaClientApplication.class, args);
        }
    }

    클 라 이언 트 가 시작 되면 서버 에서 볼 수 있 습 니 다.
    Spring Boot Admin 은 응용 정 보 를 도형 화 된 형식 으로 보 여 주 었 는데 이런 정 보 는 대부분 Spring Boot Actuator 가 제공 하 는 인터페이스 에서 나온다.
    만약 에 저희 가 하나의 Spring Boot 응용 프로그램 을 사용한다 면 감 시 된 응용 프로그램 마다 Admin Server 의 주소 정 보 를 설정 해 야 합 니 다.응용 프로그램 이 Eureka 에 등록 되 어 있 으 면 모든 응용 프로그램 을 설정 할 필요 가 없 으 며,Spring Boot Admin 은 자동 으로 등록 센터 에서 응용 프로그램 에 관 한 정 보 를 캡 처 합 니 다.
    만약 에 저희 가 Spring Cloud 의 서비스 발견 기능 을 사용 했다 면 Admin Client 클 라 이언 트 를 따로 추가 할 필요 가 없습니다.Spring Boot Server 만 있 으 면 다른 내용 은 자동 으로 설 정 됩 니 다.유레카 사용 가능.

    좋은 웹페이지 즐겨찾기