码迷,mamicode.com
首页 > 编程语言 > 详细

Spring Boot Admin

时间:2019-09-24 22:56:59      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:enable   default   stat   config   led   instance   public   star   with   

Spring Boot Admin 是一个管理和监控 Spring Boot 应用程序的开源软件,每个应用都认为是一个客户端,通过 HTTP 或者使用 Eureka 注册到 admin server 中进行展示,Spring Boot Admin UI 部分使用 Vue.js 将数据展示在前端。

Spring Boot Admin 分为:

   服务端是一个监控后台用来汇总展示所有的监控信息

     客户端就是具体的应用

1.server和client的模式

(1)server端

  添加依赖

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

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

  配置

server.port=8000
spring.application.name=Admin Server

  启动类

package com.example.management;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAdminServer
public class ManagementApplication {

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

(2)client端

  添加依赖

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

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

  配置

server.port=8001
spring.application.name=Admin Client

spring.boot.admin.client.url=http://localhost:8000
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always

  启动类

package com.example.client;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ClientApplication {

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

注:

  使用时需要先启动服务端,在启动客户端的时候打开 Actuator 的接口,并指向服务端的地址

技术图片

 

 

2.基于springcloud的模式 

(1)server

  在server端加入@EnableDiscoveryClient注解,SBA就会主动去拉取注册中心的注册服务列表,从而获取他们的服务动态信息

  注册中心使用Eureka

  添加依赖

<dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
      <version>2.1.3.RELEASE</version>
</dependency>

  配置

server.port=8000
spring.application.name=Admin Server

eureka.instance.hostname=localhost
eureka.instance.lease-renewal-interval-in-seconds=10
eureka.instance.prefer-ip-address=true
eureka.client.registry-fetch-interval-seconds=5
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.service-url.default-zone=${EUREKA_SERVICE_URL:http://localhost:8761}/eureka/

  启动类

package com.example.management;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableAdminServer
@EnableDiscoveryClient
public class ManagementApplication {

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

启动服务就可以看到注册到注册中心的服务都会被监控

 

技术图片

 

 https://blog.csdn.net/sinat_24798023/article/details/80240408

  

 

Spring Boot Admin

标签:enable   default   stat   config   led   instance   public   star   with   

原文地址:https://www.cnblogs.com/baby123/p/11580033.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!