当我们发布了微服务后,我们希望对各个应用的各个运行状况进行一个监控;这个时候spring boot admin,就出场了;
<dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server</artifactId> <version>2.0.5</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server-ui</artifactId> <version>2.0.5</version> </dependency>
@SpringBootApplication @EnableEurekaClient @EnableAdminServer public class application { public static void main(String[] args) { SpringApplication.run(application.class); } }
服务端完成
<!-- 集成Admimn监控--> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-client</artifactId> <version>2.0.5</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
spring: application: name: user boot: admin: client: url: http://localhost:8771 management: endpoints: web: exposure: include: "*"
完成
依次启动各相关项目,打开monitor地址,可以看到,对所添加的监控项目已经进行了各种监控,很方便我们查看运行状况,内容包括:
显示应用程序的监控状态、应用程序上下线监控、查看 JVM,线程信息、可视化的查看日志以及下载日志文件、动态切换日志级别、Http 请求信息跟踪等;可以自己去深入了解各监控项;
GITdemo地址: https://github.com/anson-yang/springclouddemo