ITPub博客

首页 > IT职业 > IT生活 > 使用Admin监控

使用Admin监控

IT生活 作者:shinez 时间:2021-09-09 09:33:45 0 删除 编辑

在springboot中,也提供了很全面的监控系统。这篇文章介绍一下springboot—admin监控springboot项目。

原来大致是这样的,springboot——admin——server负责当监控中心,功能类似springcloud–eureka。其他springboot作为client把自身信息注册到admin–server中去。

创建一个springboot-admin-server项目。pom文件中加入依赖,pom文件完整代码如下:


    4.0.0

    com.dalaoyang
    springboot_admin_server
    0.0.1-SNAPSHOT
    jar

    springboot_admin_server
    springboot_admin_server

    
        org.springframework.boot
        spring-boot-starter-parent
        1.5.9.RELEASE
         <!-- lookup parent from repository -->
    

    
        UTF-8
        UTF-8
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            de.codecentric
            spring-boot-admin-server
            1.5.6
        
        
            de.codecentric
            spring-boot-admin-server-ui
            1.5.6
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

在springboot启动类上加入注解@EnableAdminServer,代码如下:

package com.dalaoyang;

import de.codecentric.boot.admin.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAdminServer
public class SpringbootAdminServerApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringbootAdminServerApplication.class, args);
	}
}

到这里就配置完成了,启动项目访问http://localhost:8080/可以看到下图,目前还没有发现client

图片描述

然后创建一个springboot-admin-client项目,pom文件如下:


    4.0.0

    com.dalaoyang
    springboot_admin_client
    0.0.1-SNAPSHOT
    jar

    springboot_admin_client
    springboot_admin_client

    
        org.springframework.boot
        spring-boot-starter-parent
        1.5.9.RELEASE
         <!-- lookup parent from repository -->
    

    
        UTF-8
        UTF-8
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        

        
            de.codecentric
            spring-boot-admin-starter-client
            1.5.6
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

然后只需配置一下服务注册到admin-server即可,配置如下:

##将服务注册到admin-server
spring.boot.admin.url=http://localhost:8080

##端口号
server.port=8388

#禁用安全控制
management.security.enabled=false

启动项目,在访问http://localhost:8080/发现服务已经注册成功了,如下图

图片描述

然后点击右侧的Details,可以看到更详细的监控信息

图片描述

Details:

图片描述
Metrices:

图片描述

Enviroment:

图片描述

Logging:

图片描述

JMX:

图片描述

Threads:

图片描述

Audit:

图片描述

Trace:

图片描述

源码下载 :大老杨码云

个人网站:https://dalaoyang.cn


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3127/viewspace-2804721/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: List扑克牌游戏
请登录后发表评论 登录
全部评论

注册时间:2019-08-30

  • 博文量
    0
  • 访问量
    932