前一篇写了入门后,那么第二个动作就是跟踪下源码了, 本文整理下看源码时主要的类 Spring-Boot-Actuator 自动装配 引入spring-boot-actuator-autoconfigure
想学习下spring-boot-actuator, 发现需要前置技能: JMX; 重新温习下JMX,并且根据spring官网对actuator进行quickstart spring-boot-actuator article/1892726 官方文档 JMX官方demo https://docs.oracle.com/javase/8/docs/technotes/guides/jmx/examples.html spring-boot-actuator sping-boot-actuator官方文档示例及文档 https://gitee.com/eeaters/hogwarts/tree/master/spring-module/actuator spring-boot-actuator Management Extension)是java的标准的管理拓展规范 , 日常工作中常用的系统监控,如:内存,cpu使用率,线程数,垃圾回收等监控曲线都可以通过jmx来进行管理;并且可以运行时动态修改配置 spring-boot-actuator MBean的创建, - 默认情况下服务会使用rmi协议进行通讯, 但是rmi协议是JAVA的轻量级RPC通讯框架,对于非JVM虚拟机上的服务通讯上受限制,而现在中性的通讯框架大都选择http进行通讯, spring-boot-actuator
~ 本篇内容包括:spring-boot-actuator 模块介绍、spring-boot-actuator 初体验、health 端点、metrics 端点、loggers 端点、beans 端点 、关于自定义 Endpoint ---- 文章目录 一、spring-boot-actuator 模块介绍 1、关于 spring-boot-actuator 模块 2、spring-boot-actuator 源码地址 3、启用 spring-boot-actuator 模块 二、spring-boot-actuator 初体验 1、项目中添加 Maven 依赖 2、启动项目访问 Api 3、添加 actuator 2、spring-boot-actuator 源码地址 spring-boot-actuator 位于 spring-boot 项目中。 /spring-boot-actuator 3、启用 spring-boot-actuator 模块 对于 Maven: <dependencies> <dependency> <groupId>
前言 最近在一个webflux项目中使用spring-boot-actuator提供的健康检查端点时出了点问题,故对spring-boot-actuator的项目构造,工作原理进行了全面的梳理,标题之所以写明 health的工作原理,是因为spring-boot-actuator着实是个大工程,除了提供health端点,还包含了env,log,dump等诸多功能,下面会侧重health健康检查部分,详细探索下 <artifactId>spring-boot-starter-actuator</artifactId> </dependency> 在这个starter里面会包含两个依赖,一个是功能实现spring-boot-actuator <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-actuator CompositeHealthIndicator(healthAggregator, registry)); } } 可以看到前提条件是已经有一个健康指示注册器单例实例了 health健康检查实现 在spring-boot-actuator
但是服务监控这块内容往往是最容易被忽略的一块内容,今天我们一起来学习一下使用spring-boot-actuator进行服务监控。 spring-boot-actuator提供了监控端点,这些端点直接返回JSON字符串,通过这些端点可以查询服务运行状况,为了防止端点直接暴露,一般情况下会使用安全框架,如Spring Security 1.1 如何使用 在项目中引入spring-boot-actuator的依赖,就可以正常使用了 <dependency> <groupId>org.springframework.boot</groupId
在之前发布的《Spring Boot Actuator监控端点小结》一文中,我们介绍了Spring Boot Actuator模块为应用提供的强大监控能力。在Spring Boot应用中,我们只需要简单的引入`spring-boot-starter-actuator`依赖就能为应用添加各种有用的监控端点。其中,`/health`端点能够全面检查应用的健康状态,该端点也被Spring Cloud中的服务治理(Eureka、Consul)用来检查应用的健康状态。所以,在使用Spring Cloud构建微服务架构
Client端配置 这里使用上一章的演示项目——spring-boot-actuator做为客户端。 为了监控更多的状态信息,我们在客户端引入spring-boot-actuator依赖。 spring-boot-admin配合spring-boot-actuator实现多服务监控,不仅能查看提供服务监控信息的ui,而且可以监控更加全面的内容。
Client端配置 这里使用上一章的演示项目——spring-boot-actuator做为客户端。 admin: client: # 服务端地址 url: http://localhost:7019 效果如下: 为了监控更多的状态信息,我们在客户端引入spring-boot-actuator spring-boot-admin配合spring-boot-actuator实现多服务监控,不仅能提供查看服务监控信息的ui,而且可以监控更加全面的内容。
之前章节SpringBoot核心技术:探究Actuator的默认开放节点 & 详细健康状态讲解了spring-boot-actuator默认开放的节点以及如何修改查看详细的健康信息,那我们怎么设置开放指定的节点访问呢 本章目标 开放spring-boot-actuator的指定节点访问。 base-path: / # 开放指定节点 exposure: include: "*" 内置节点列表 开放全部节点后在项目启动时,控制台会打印已经映射的路径列表,spring-boot-actuator
但是服务监控这块内容往往是最容易被忽略的一块内容,今天我们一起来学习一下使用spring-boot-actuator进行服务监控。 spring-boot-actuator提供了监控端点,这些端点直接返回JSON字符串,通过这些端点可以查询服务运行状况,为了防止端点直接暴露,一般情况下会使用安全框架,如Spring Security 1.1 如何使用 在项目中引入spring-boot-actuator的依赖,就可以正常使用了 <dependency> <groupId>org.springframework.boot</groupId
核心技术包(spring-boot-project) 二、Spring Boot 核心模块 1、spring-boot 2、spring-boot-actuator-autoconfigure 3、spring-boot-actuator 2、spring-boot-actuator-autoconfigure spring-boot-actuator-autoconfigure 提供了 spring-boot-actuator 的自动配置功能 3、spring-boot-actuator 当系统运行时,我们想要了解系统运行的情况,比如程序是否存活、Jvm 状态怎么样。 spring-boot-actuator 是 spring-boot 周边组件之一,主要是用来查询或监控 spring-boot 项目各种组件、各种维度的度量指标,比如环境变量信息、日志级别、spring
refresh 客户端添加依赖(pom.xml) <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-actuator refresh 常见问题 配置文件不存在:可能是没有配置spring.cloud.config.server.git.search-paths=config refresh接口不存在:可能是没有引入spring-boot-actuator
6) spring-boot-actuator 这个跟SpringBoot的监控有关,也是SpringBoot的新特性之一。可以通过HTTP端点或JMX等来管理和监控应用。 spring-boot模块下的子模块,不用慌,我们要进行解读的模块不多,我们真正要看的模块有spring-boot,spring-boot-autoconfigure,spring-boot-starters和spring-boot-actuator module(注意除去spring-boot-dependencies(pom.xml)),比如有spring-boot(pom.xml),spring-boot-starters(pom.xml)和spring-boot-actuator
micrometer-registry-prometheus' compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator' 配置文件添加 # spring-boot-actuator
本章目标 通过spring-boot-actuator完成系统运行监控,实时了解程序运行的环境是否健康。 总结 通过本章的讲解我们明白了spring-boot-actuator默认开放了health、info两个节点,通过配置健康检查详细信息可以查看硬盘相关的运行健康状态。
spring-cloud-config-server', version: '1.3.2.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-starter-consul-discovery', version: '1.3.1.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-starter-consul-discovery', version: '1.3.1.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-starter-zuul', version: '1.3.4.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-netflix-turbine', version: '1.3.4.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator
当引入了上面的依赖,默认会引入actuator相关的两个项目: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-actuator org.springframework.boot</groupId> <artifactId>spring-boot-actuator-autoconfigure</artifactId> </dependency> 其中spring-boot-actuator " } ], /info:就是在配置文件中配置的以info开头的信息,如配置为: info: app: name: spring-boot-actuator version: 1.0.0 返回结果: { "app":{ "name":"spring-boot-actuator", "version":"1.0.0" } }
from the following locations: jar:file:/Users/lijingyong/.m2/repository/org/springframework/boot/spring-boot-actuator loaded from the following location: file:/Users/lijingyong/.m2/repository/org/springframework/boot/spring-boot-actuator
6) spring-boot-actuator 这个跟SpringBoot的监控有关,也是SpringBoot的新特性之一。可以通过HTTP端点或JMX等来管理和监控应用。 spring-boot模块下的子模块,不用慌,我们要进行解读的模块不多,我们真正要看的模块有spring-boot,spring-boot-autoconfigure,spring-boot-starters和spring-boot-actuator module(注意除去spring-boot-dependencies(pom.xml)),比如有spring-boot(pom.xml),spring-boot-starters(pom.xml)和spring-boot-actuator
spring-cloud-config-server', version: '1.3.2.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-starter-eureka', version: '1.3.4.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-starter-eureka', version: '1.3.4.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-starter-zuul', version: '1.3.4.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator spring-cloud-starter-eureka', version: '1.3.4.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-actuator