zoukankan      html  css  js  c++  java
  • Spring Boot 使用actuator监控与管理

    微服务架构下,庞大的系统拆分成多个独立的系统,应用部署的的数量增加,维护的复杂性增加,为了高效的运维,需要一套自动化的监控运维机制,为了使运维系统获取各微服务应用的相关指标,spring boot提供spring-boot-starter-actuator模块,提供一系列监控的端点.

    入门demo:

      环境:springboot版本:2.1.3.RELEASE

      在spring boot工程的基础上添加依赖

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

     启动访问:http://localhost/actuator/health

    spring-boot-starter-actuator提供多个默认端点,可以启用或禁用每个端点。要远程访问端点,还必须通过JMX或HTTP公开端点。大多数应用程序选择HTTP,其中端点的ID加上/actuator的前缀映射到URL,例如上面,显示应用程序健康信息的URL./actuator/health.提供的端点有:

    ID Description web默认是否开启
    auditevents 为当前应用程序公开审计事件信息 No
    beans 显示应用程序中所有Spring bean的完整列表 No
    caches 公开可用的缓存 No
    conditions 显示在配置和自动配置类上评估的条件,以及它们匹配或不匹配的原因 No
    configprops 显示所有已整理的@ConfigurationProperties修饰的列表 No
    env Spring的ConfigurableEnvironment公开属性 No
    health 显示应用程序健康信息 Yes
    heapdump 生成堆信息文件 No
    httptrace 显示HTTP跟踪信息(默认情况下,最后100个HTTP请求-响应交换) No
    info 显示应用程序信息 Yes
    metrics 显示当前应用程序的“度量”信息 No
    mappings 显示所有@RequestMapping路径的列表 No
    scheduledtasks 显示应用程序中的计划任务 No
    threaddump 执行线程转储 No

    由于端点可能包含敏感信息,因此应该仔细考虑何时公开它们,默认情况下web下只公开info, health两个端点,可以通过application.properties配置控制

    management.endpoints.web.exposure.include=*
    management.endpoints.web.exposure.exclude=env,beans

    如上:management.endpoints.web.exposure.include=*  代表公开使用端点

      management.endpoints.web.exposure.exclude=env,beans 标示排除env,beans俩端点

    当两个配置出现冲突时,management.endpoints.web.exposure.exclude的优先级更高,即spring boot会公开除了env,beans的所有端点

  • 相关阅读:
    Blender基础操作
    反汇编及linux下edb的下载
    混淆矩阵(confusion_matrix)含义
    Python大数据第三次的作业
    Python的DataFrame基础使用
    Python数据标准化
    爬虫之xpath
    luffy项目上线
    爬虫之selenium
    celery
  • 原文地址:https://www.cnblogs.com/2nao/p/10437517.html
Copyright © 2011-2022 走看看