spring-boot-starter-actuator功能简介

根据应用依赖和配置自动创建出来的监控和管理端点。通过这些端点,我们可以实时获取系统应用的各项监控指标。

spring-boot-starter-actuator功能集成

第一步:添加相关jar包依赖

        <!--srping-boot-actuator--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>

第二步:application.properties 配置Spring-Boot-Actuator配置

#spring-boot-actuator配置
#开放所有的web Endpoints
management.endpoints.web.exposure.include=*

第三步:获取监控端点详细信息和效果展示

通过访问:http://localhost:8082/actuator,获取监控端点详细信息

字符串格式化:

{"_links":{"self":{"href":"http://localhost:8082/actuator","templated":false},"archaius":{"href":"http://localhost:8082/actuator/archaius","templated":false},"auditevents":{"href":"http://localhost:8082/actuator/auditevents","templated":false},"beans":{"href":"http://localhost:8082/actuator/beans","templated":false},"caches-cache":{"href":"http://localhost:8082/actuator/caches/{cache}","templated":true},"caches":{"href":"http://localhost:8082/actuator/caches","templated":false},"health":{"href":"http://localhost:8082/actuator/health","templated":false},"health-component":{"href":"http://localhost:8082/actuator/health/{component}","templated":true},"health-component-instance":{"href":"http://localhost:8082/actuator/health/{component}/{instance}","templated":true},"conditions":{"href":"http://localhost:8082/actuator/conditions","templated":false},"configprops":{"href":"http://localhost:8082/actuator/configprops","templated":false},"env":{"href":"http://localhost:8082/actuator/env","templated":false},"env-toMatch":{"href":"http://localhost:8082/actuator/env/{toMatch}","templated":true},"info":{"href":"http://localhost:8082/actuator/info","templated":false},"loggers":{"href":"http://localhost:8082/actuator/loggers","templated":false},"loggers-name":{"href":"http://localhost:8082/actuator/loggers/{name}","templated":true},"heapdump":{"href":"http://localhost:8082/actuator/heapdump","templated":false},"threaddump":{"href":"http://localhost:8082/actuator/threaddump","templated":false},"metrics-requiredMetricName":{"href":"http://localhost:8082/actuator/metrics/{requiredMetricName}","templated":true},"metrics":{"href":"http://localhost:8082/actuator/metrics","templated":false},"scheduledtasks":{"href":"http://localhost:8082/actuator/scheduledtasks","templated":false},"httptrace":{"href":"http://localhost:8082/actuator/httptrace","templated":false},"mappings":{"href":"http://localhost:8082/actuator/mappings","templated":false},"refresh":{"href":"http://localhost:8082/actuator/refresh","templated":false},"features":{"href":"http://localhost:8082/actuator/features","templated":false},"service-registry":{"href":"http://localhost:8082/actuator/service-registry","templated":false}}
}

spring-boot-starter-actuator模块生成的原生监控端点,分为三大类:

  1. 应用配置类:获取应用程序中加载的应用配置、环境变量、自动化配置报告等与SpringBoot应用密切相关的配置类信息;这类端点可以帮助我们获取一系列关于Spring应用配置内容的详细报告,比如自动化配置的报告、Bean创建的报告、环境属性的报告等。
  2. 度量指标类:获取应用程序运行过程中用于监控的度量指标,比如内存信息、线程池信息、HTTP请求统计等;
  3. 操作监控类:提供了对应用的关闭等操作类功能;

以上三类监控端点的详细信息,下面我们详细来说明。

第四步:监控端点信息描述

应用配置类:默认启用

  1. /autoconfig: 该端点用来获取应用的自动化配置报告,其中包括所有自动化配置的候选项,同时列举了每个候选项是否满足自动化配置的各个先决条件。该端点可以帮助我们方便地找到一些自动化配置为什么没有生效的具体原因。报告内容分为两部分,如下:
    (1)positiveMatches中返回的是条件匹配成功的自动化配置;
    (2)negativeMathches中返回的是条件匹配不成功的自动化配置。
  2. /beans: 该端点用来获取应用上下文中创建的所有Bean。包含的具体信息如下:
    (1)bean:Bean的名称;
    (2)scope: Bean的作用域;
    (3)type: Bean的Java类型;
    (4)resource: class文件的具体路径;
    (5)dependencies: 依赖的Bean的名称;
  3. /configprops: 该端点用来获取应用中配置的属性信息报告。我们可以通过该报告来看到各个属性的配置路径,比如我们要关闭端点,就可以使用endpoints.configprops.enabled=false来完成设置。
  4. /env: 该端点用来获取应用所有可用的环境属性报告,具体包括环境变量、JVM属性、应用的配置属性、命令行中的参数。通过该端点返回的信息,我们可以看到当前应用加载的配置信息,可以结合@ConfigurationProperties注解将它们引入到应用程序中使用。对于一些敏感属性信息,比如在属性名中包含password,secret,key这些关键词,在返回的时候会使用*来替换。
  5. /mappings: 该端点用来返回所有Spring MVC的控制器映射关系报告。返回的信息有:
    (1)bean属性: 标识该映射关系的请求处理器;
    (2)method属性:标识该映射关系的具体处理类和处理函数;
  6. /info:该端点用来返回一些应用自定义的信息。默认情况下,该端点只会返回一个空的JSON内容。我们可以在application.properties配置文件中设置一些以info为前缀的属性配置信息,就能看到效果。

度量指标类:默认启用

  1. /metrics: 该端点用来返回当前应用的各类重要度量指标,比如内存信息、线程信息、垃圾回收信息等。具体信息包含如下:
    (1)系统信息:包括处理器数量processors、运行时间uptime和instance.uptime、系统平均负载systemload.average;
    (2)mem.*: 内存概要信息,包括分配给应用的总内存数量以及当前空闲的内存数量,这些信息来自java.lang.Runtime;
    (3)heap.*: 堆内存使用情况。这些信息来自java.lang.management.MemoryMXBean接口中getHeapMemoryUsage方法获取的java.lang.management.MemoryUsage;
    (4)nonheap.*: 非堆内存使用情况。这些信息来自java.lang.management.MemoryMXBean接口中getNonHeapMemoryUsage方法获取java.lang.management.MemoryUsage;
    (5)threads.*: 线程使用情况,包括线程数、守护线程(daemon)、线程峰值(peak)等,这些信息来自java.lang.management.ThreadMXBean;
    (6)classes.*: 应用加载和卸载的类统计,这些信息来自java.lang.managemeng.ClassLoadingMXBean;
    (7)gc.*: 垃圾收集器的详细信息,包括垃圾回收次数gc.ps_scavenge.count、垃圾回收消耗时间gc.ps_scavenge.time、标记-清除算法的次数gc.ps_marksweep.count、标记-清除算法的消耗时间gc.ps_marksweep.time。这些信息来自java.lang.management.GarbageCollectorMXBean;
    (8)httpsessions.*: Tomcat容器的会话使用情况。包括最大会话数httpsessions.max和活跃会话数httpsessions.active。该度量指标信息仅在引入嵌入式Tomcat作为应用容器的时候才会提供;
    (9)gauge.*: HTTP请求的性能指标之一,它主要用来反映一个绝对值。
    (10)counter.*: HTTP请求的性能指标之一,它主要作为计数器来使用,记录了增加量和减少量。
    报告的具体内容如下:
  2. /health: 该端点用来获取应用的各类健康指标信息。在spring-boot-starter-actuator模块中自带实现了一些常用资源的健康指标检测器,这些健康指标检测器都是通过HealthIndicator接口实现,并且会根据依赖关系的引入实现自动化配置。常见的一些健康指标检测器如下:
    (1)DiskSpaceHealthIndicator: 低磁盘空间检测;
    (2)DataSourceHealthIndicator: 检测DataSource的链接是否成功;
    (3)MongoHealthIndicator: 检测Mongo数据库是否可用;
    (4)RabbitHealthIndicator: 检测Rabbit服务器是否可用;
    (5)RedisHealthIndicator: 检测Redis服务器是否可用;
    (6)SolrHealthIndicator: 检测Solr服务器是否可用;
    我们也可用通过实现HealthIndicator接口来自定义自己的健康指标检测器;
    报告的具体内容如下:
  3. /dump: 该端点用来暴露程序运行中的线程信息。它使用java.lang.management.ThreadMXBean的dumpAllThreads方法来返回所有含有同步信息的活动线程详情;
  4. /trace: 该端点用来返回基本的HTTP跟踪信息。默认情况下,跟踪信息的存储采用org.springframework.boot.actuate.trace.InMemoryTraceRepository实现的内存方式,始终保留最近的100条请求记录。

操作控制类:需要通过属性配置来开启操作

1./shutdown: 该端点用来实现关闭应用的远程操作,需要配置属性endpoints.shutdown.enable=true才能实现。该操作非常危险,不建议使用。

SpringBoot 集成Spring Boot Actuator 监控管理相关推荐

  1. Spring Boot Actuator监控页面报错解决

    今天在访问Spring Boot Actuator监控页面的时候报错了,之前都没遇到这种情况,大概的意思就是无权限访问 <html><body><h1>Whitel ...

  2. (转)Spring Boot (十九):使用 Spring Boot Actuator 监控应用

    http://www.ityouknow.com/springboot/2018/02/06/spring-boot-actuator.html 微服务的特点决定了功能模块的部署是分布式的,大部分功能 ...

  3. spring boot actuator监控详细介绍一(超级详细)

    spring boot actuator介绍 Spring Boot包含许多其他功能,可帮助您在将应用程序推送到生产环境时监视和管理应用程序. 您可以选择使用HTTP端点或JMX来管理和监视应用程序. ...

  4. 使⽤用 Spring Boot Actuator 监控应⽤

    1.美图 2.概述 微服务的特点决定了功能模块的部署是分布式的,⼤部分功能模块都是运行在不同的机器上,彼此通过服务调⽤进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现异常如何快速定位便成为 ...

  5. SpringBoot实战(十二):集成 Spring Boot Admin 监控

    强烈推荐一个大神的人工智能的教程:http://www.captainbed.net/zhanghan [前言] 程序开发完实现相应的功能只是一个部分,如何让系统在线上运行更好创造更高的价值是另外一个 ...

  6. Spring Boot Actuator [监控与管理]

    1. 如何添加 2. actuator 的原生端点(API) 2.1 应用类配置 2.1.1 http://localhost:8080/actuator/conditions 2.1.2 http: ...

  7. Spring Boot Actuator监控关闭

    可以使用如下属性:management.endpoints.enabled-by-default=false * 在YAML中有特殊的含义,所以如果想使用include或者exclude包含所有的端点 ...

  8. 高级版的 jvisualvm :Spring Boot Admin 监控 Spring Boot 微服务项目

    前奏:先说一下 Java VisualVM Java VisualVM 是一个能够监控 JVM 的 jdk 自带的图形化工具: 在 $JAVA_HOME/bin 目录下,可直接运行它. 要想监控远程服 ...

  9. 如何将 Spring Boot Actuator 的指标信息输出到 InfluxDB 和 Prometheus

    来源:SpringForAll社区 Spring Boot Actuator是Spring Boot 2发布后修改最多的项目之一.它经过了主要的改进,旨在简化定制,并包括一些新功能,如支持其他Web技 ...

最新文章

  1. Linux技巧总结(个人经验版)
  2. 论文:Multi-Objective Modified Grey Wolf Optimizer for Optimal Power Flow-最优潮流
  3. Confluence 6 指派和撤销空间权限
  4. Fiat–Shamir heuristic 启发式的应用 理解 代码实现
  5. 微服务之配置中心ConfigKeeper
  6. 浅析Linux线程调度
  7. 自如总部摘牌?官方回应:更换logo 业务一切正常
  8. 输入网址的时候,浏览器是如何判断你是http协议还是https协议的
  9. STC学习:看谁手速快
  10. redis_lua_nginx环境配置过程
  11. ps,pr,ae安装插件出现“无法加载扩展,因为它未正确签署”解决办法
  12. Python数据挖掘实战-唐宇迪-专题视频课程
  13. java-php-python-ssm-民航售票管理系统-计算机毕业设计
  14. 008 使用MyBatis,easyUI实现CRUD操作样例-CUD(CRUD完毕)
  15. C/C++类型到Ada
  16. SQLI DUMB SERIES-4
  17. 程序员是如何开灯的 白话闲聊mqtt协议
  18. 狂欢,不过是一群人的孤单--来自人人
  19. android系统如何获得外置卡路径
  20. Python jieba库简介和使用

热门文章

  1. android aidl通信,Android的AIDL通信机制
  2. mapbox创建自定义marker图标绑定弹框展示信息
  3. 操纵Review被封店,申诉信
  4. AS5600磁编码器原理图和驱动
  5. html幽灵空白节点
  6. 经典又耐人寻味的一组冷笑话
  7. GPT转MBR分区格式图文教程
  8. oracle中varchar 和 nvarchar2的区别,Oracle中char,varchar,varchar2,nvarchar,nvarchar2的区别
  9. xtrabackup mysql_使用xtrabackup实现MySQL主从复制
  10. 手机计算机用英语怎么说,什么软件可以自动将手机上显示的英语翻译成汉字