美文网首页SpringCloud服务器后端开发
通过SpringAdmin搭建简单的监控平台

通过SpringAdmin搭建简单的监控平台

作者: 洋葱cy | 来源:发表于2018-03-16 15:00 被阅读631次

之前通过Actuator可以通过一些Url查看程序运行状态

集成SpringAdmin 可以可视化监控状态

步骤1

1.搭建SpringBoot Admin服务
2.将需要被监测的应用注册到admin服务
3.在SpringBoot admin服务页面中可以管理各应用的监控情况

首先第一步 创建SpringBoot项目 admin

image.png
pom文件中加入 admin依赖
admin server依赖
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-server</artifactId>
    <version>1.5.2</version>
</dependency>
admin-ui依赖 用于显示UI界面
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-server-ui</artifactId>
    <version>1.5.2</version>
</dependency>
启动项中加入 @EnableAdminServer注解开启admin
@SpringBootApplication
@EnableAdminServer
public class AdminApplication {

    public static void main(String[] args) {
        SpringApplication.run(AdminApplication.class, args);
    }
}
配置文件中指定启动端口为8060 (随意)
server:
  port: 8060

启动项目
这时候Admin的服务端已经搭建完成

客户端集成Admin

将客户端web项目 注册到Admin中

web的pom里添加客户端依赖

  <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>1.5.2</version>
  </dependency>
将web注册到Admin的监控之中
spring:
  boot:
    admin:
      url: http://localhost:8060  #admin的地址
启动web和admin项目
访问admin项目
image.png

web项目已经被注册进来了 我们可以点击进去查看详情

相关文章

网友评论

    本文标题:通过SpringAdmin搭建简单的监控平台

    本文链接:https://www.haomeiwen.com/subject/healqftx.html