学习笔记:微服务-17 spring boot admin server微服务运行监控
Spring Boot Admin 是一个管理和监控Spring Boot 应用程序的开源软件。每个应用都认为是一个客户端,通过HTTP或者使用 Eureka注册到admin server中进行展示,Spring Boot Admin UI部分使用AngularJs将数据展示在前端。
服务端和客户端都需要配置
一、spring boot admin server服务端配置
1.新建一个spring boot project,pom.xml 加入依赖
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.1.1</version>
</dependency>
2. 配置文件
server.port=8501
spring.application.name=MicroserviceAdminServer8501
spring.cloud.discovery.enabled=true
eureka.client.serviceUrl.defaultZone=http://admin:[email protected]:8101/eureka/,http://admin:[email protected]:8102/eureka/
management.endpoints.web.exposure.include="*"
management.endpoint.health.show-details=ALWAYS
3.启动项加入注解
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
@SpringBootApplication
public class MicroserviceAdminServer8501Application {
public static void main(String[] args) {
SpringApplication.run(MicroserviceAdminServer8501Application.class, args);
}
二、spring boot admin client客户端配置
1.在某一个spring boot 项目中增加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.1.1</version>
</dependency>
2.配置文件增加
spring.boot.admin.client.url=http://centos7.linbsoft.com:8501 # admin server url
spring.boot.admin.client.instance.management-base-url=http://centos7.linbsoft.com:8803 #本项目url
spring.boot.admin.client.instance.service-base-url=http://centos7.linbsoft.com:8803
management.endpoints.web.exposure.include=* #暴露所有监控项
三、测试
启动eureka server,admin server ,admin client项目
浏览服务端url