SpringBoot:Boot Admin Server

目录

一、创建项目

二、基础设置

三、注册客户端

四、监控项目


指标监控可视化文档:用于管理 Spring Boot 应用程序的管理 UIicon-default.png?t=M85Bhttps://github.com/codecentric/spring-boot-adminSpring Boot Admin Reference Guideicon-default.png?t=M85Bhttps://codecentric.github.io/spring-boot-admin/2.5.1/#getting-started


一、创建项目

 

 就勾选Spring Web项目即可

 

二、基础设置

(1) 依赖引入

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

(2) 开启服务器监控功能

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

@EnableAdminServer    //开启服务器监控功能
@SpringBootApplication
public class BootAdminServerApplication {

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

}

(3) SpringBoot配置文件

server.port=8888

(4) 启动项目

浏览器输入:http://localhost:8888/

打开的管理页面如下:

三、注册客户端

客户端中的数据需要被服务器收集

(1) 添加依赖

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

(2) 客户端把数据传递给服务器

在需要监控的项目中的application.yaml配置:(注意是另一个项目application.yaml,因为要监控另一个项目)

spring:
  boot:
    admin:
      client:
        url: http://localhost:8888

开启所有端点的监控,同样是在需要被监控的项目中进行配置(这里还是application.yaml)

# management 是所有actuator的配置
# management.endpoint.端点名.xxxx  对某个端点的具体配置
management:
  endpoints:
    enabled-by-default: true  #默认开启所有监控端点  true
    web:
      exposure:
        include: '*' # 以web方式暴露所有端点

四、监控项目

客户端和服务器连接好后,就可以打开SpringBoot Admin Server的管理界面了,实时监控项目

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值