您的当前位置:首页正文

Spring Cloud入门-Admin服务监控中心(Hoxton版本)(1)

2024-11-24 来源:个人技术集锦

Spring Boot Admin 可以对SpringBoot应用的各项指标进行监控,可以作为微服务架构中的监控中心来使用,本文将对其用法进行详细介绍。

Spring Boot Admin 简介


SpringBoot应用可以通过Actuator来暴露应用运行过程中的各项指标,Spring Boot Admin通过这些指标来监控SpringBoot应用,然后通过图形化界面呈现出来。Spring Boot Admin不仅可以监控单体应用,还可以和Spring Cloud的注册中心相结合来监控微服务应用。

Spring Boot Admin 可以提供应用的以下监控信息:

  • 监控应用运行过程中的概览信息;

  • 度量指标信息,比如JVM、Tomcat及进程信息;

  • 环境变量信息,比如系统属性、系统环境变量以及应用配置信息;

  • 查看所有创建的Bean信息;

  • 查看应用中的所有配置信息;

  • 查看应用运行日志信息;

  • 查看JVM信息;

  • 查看可以访问的Web端点;

  • 查看HTTP跟踪信息。

创建admin-server模块


在pom.xml中添加相关依赖:

org.springframework.boot

spring-boot-starter-web

de.codecentric

spring-boot-admin-starter-server

在application.yml中进行配置:

server:

port: 9301

spring:

application:

name: admin-server

在启动类上添加@EnableAdminServer来启用admin-server功能:

@EnableAdminServer

@SpringBootApplication

public class AdminServerApplication {

public static void main(String[] args) {

SpringApplication.run(AdminServerApplication.class, args);

}

}

创建admin-client模块


这里我们创建一个admin-client模块作为客户端注册到admin-server。

在pom.xml中添加相关依赖:

org.springframework.boot

spring-boot-starter-web

de.codecentric

spring-boot-admin-starter-client

在application.yml中进行配置:

server:

port: 9305

spring:

application:

name: admin-client

显示全文