指标监控可视化
这是一个github 的指标监控项目,自己引入一下依赖
地址:https://codecentric.github.io/spring-boot-admin/2.5.1/#_configuration_options
首先 创建一个新项目,引入依赖
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
然后在主程序类上加上监控功能注解 @EnableAdminServer
@EnableAdminServer
@SpringBootApplication
public class CodecentricApplication {
public static void main(String[] args) {
SpringApplication.run(CodecentricApplication.class, args);
}
}
应用端口冲突的再在配置文件里改一下端口号
server:
port: 8088
然后启动项目
然后在需要被监控的项目上,引入依赖,添加配置
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.5.1</version>
</dependency>
设置推送消息地址,同时使所有 endpoints 暴露在web环境下。
boot:
admin:
client:
url: http://localhost:8088
management:
endpoints:
web:
exposure:
include: '*'
然后启动这个项目,再去访问新创建的那个项目,就会显示多加了一个监控的项目,点击项目,就能看到之前自定义的endpoint信息,以及一些指标监控内容,很好玩,指标监控日志配置等很方便。