监控 ---- Spring Boot Admin

1、前置

文档地址: https://codecentric.github.io/spring-boot-admin/2.3.1/#jmx-bean-management

版本

  • Spring Boot: 2.2.5.RELEASE
  • spring-boot-admin-starter-client: 2.2.4
  • spring-boot-admin-starter-server: 2.3.0

2、效果图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

3、服务端(查看监控):

<parent>
  <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
   <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.3.0</version>
   </dependency>

   <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-security</artifactId>
   </dependency>
</dependencies>
server:
  port: 11911

spring:
  security:
    user:
      name: admin
      password: admin
      roles: admin
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@EnableAdminServer // 开启 springboot admin 服务端
@SpringBootApplication
public class BaMoApplication {

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

}

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @author Chaim
 * @date 2021/7/28 17:02
 */
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .formLogin().loginProcessingUrl("/login")
                .and().httpBasic()
                .and()
                .csrf()
                .disable();
    }
}

4、客户端(被监控):

<parent>
  <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <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.2.4</version>
    </dependency>

    <!-- java 管理扩展基于此包展示 -->
    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-core</artifactId>
    </dependency>
</dependencies>
server:
  port: 8080
  tomcat:
    # tomcat检测
    mbeanregistry:
      enabled: true

# 开放端点用于springboot admin的监控
management:
  endpoints:
    web:
      exposure:
        include: "*"
  server:
    port: 8088
  endpoint:
    shutdown:
      enabled: true
    health:
      show-details: always

spring:
  # 监控配置
  boot:
    admin:
      client:
        # admin 服务端地址
        url: http://127.0.0.1:11911
        username: admin
        password: admin
        instance:
          # 名字
          name: TEST环境
          # 主页地址|登录地址
          service-url: http://www.baidu.com
          # management工具地址
          management-url: http://127.0.0.1:${management.server.port}/actuator
          # management健康检查地址
          health-url: http://127.0.0.1:${management.server.port}/actuator/health

5、后序

1、可以部署一个服务端, 监控多个客户端
2、对应的参数就不一一解释了, 太多了,也不搬砖了, 给大家贴几个地址吧
SpringBoot2.0 Actuator监控指标分析: https://blog.csdn.net/cowbin2012/article/details/85220046
Spring Boot Admin配置属性: https://blog.csdn.net/it_lihongmin/article/details/95250519
3、最主要的地址: https://codecentric.github.io/spring-boot-admin/2.3.1/#_what_is_spring_boot_admin
4、官方GitHub地址: https://github.com/codecentric/spring-boot-admin

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值