SpringBoot Admin 2.1.5监控微服务的基本配置

1. 介绍

SpringBoot Admin可以看作是Spring actuator监控的一个UI界面,可以很方便的查看服务的运行情况。本篇文章只做一个简单的基本配置介绍。

1.1 admin server配置

基于eureka,将admin server注册到服务注册中心,则其他微服务不要任何改动即可被监控(前提是是暴露了监控端点)。
加入依赖

	<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-server</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

注解AdminServer

@EnableAdminServer

application.yml配置

	spring:
	  application:
	    name: your app name
	  profiles:
	    active: dev
	  security:
	    user:
	      name: "admin"
	      password: "admin"
	management:
	  endpoints:
	    web:
	      exposure:
	        include: "*"
	  endpoint:
	    health:
	      show-details: always

**需要注意的是:**由于默认的management端点未完全开放,所以可能最后展示出的信息不全,这里使用management.endpoints.web.exposure.include="*"方式暴露所有监控端点,以便查看更详细的信息。

2. 启动admin server

首先启动eureka server,然后依次启动admin server以及各个微服务:
在这里插入图片描述
然后访问:http://localhost:9000

在这里插入图片描述

点击具体的服务即可查看监控信息:

在这里插入图片描述

在这里插入图片描述

原文地址:https://www.cnblogs.com/cnsec/p/13286626.html