• springcloud-整合 Spring Boot Actuator


    • 指标监控是什么?
    • 为微服务集成 Spring Boot Actuator
    • 基础指标监控的端点

      Spring Boot Actuator 是 Spring Boot 管方提供的监控组件。我们只需要在项目中添加该依赖就可以整合 Spring Boot Actuator

    端点(Spring Boot 2.x)描述HTTP 方法是否敏感端点(Spring Boot 1.x)
    conditions 显示自动配置的信息 GET autoconfig
    beans 显示应用程序上下文所有的 Spring bean GET beans
    configprops 显示所有 @ConfigurationProperties 的配置属性列表 GET configprops
    dump 显示线程活动的快照 GET dump
    env 显示环境变量,包括系统环境变量以及应用环境变量 GET env
    health 显示应用程序的健康指标,值由 HealthIndicator 的实现类提供;结果有 UP、 DOWN、OUT_OF_SERVICE、UNKNOWN;如需查看详情,需配置:management.endpoint.health.show-details GET health
    info 显示应用的信息,可使用 info.* 属性自定义 info 端点公开的数据 GET info
    mappings 显示所有的 URL 路径 GET mappings
    metrics 显示应用的度量标准信息

    添加依赖

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

    运行

    mvn spring-boot:run

    C:Usersljavademomicroservice-provider-user>curl http://localhost:8000/actuator/health
    {"status":"UP"}

    配置文件

    management:
      endpoint:
        health:
          # 是否展示健康检查详情
          show-details: always
    
    mvn spring-boot:run

    sersljavademomicroservice-provider-user>curl http://localhost:8000/actuator/health {"status":"UP","components":{"db":{"status":"UP","details":{"database":"H2","validationQuery":"isValid()"}},"diskSpace":{"status":"UP","details":{"total":127357939712,"free":29238120 448,"threshold":10485760,"exists":true}},"ping":{"status":"UP"}}}

     

    如果想暴露所有监控点

    management:
    endpoints:
    web:
    exposure:
    include: '*'

    health:
    # 是否展示健康检查详情
    show-details: always


    C:Usersljavademomicroservice-provider-user>curl http://localhost:8000/actuator/health
    {"status":"UP"}

      

    菜鸟的自白
  • 相关阅读:
    MATLAB入门学习(一)
    4.21小练
    poj2312 Battle City 【暴力 或 优先队列+BFS 或 BFS】
    Mutual Training for Wannafly Union #2
    4.7-4.9补题+水题+高维前缀和
    CodeForces 91A Newspaper Headline
    codeforces 792C. Divide by Three
    3.26-3.31【cf补题+其他】
    poj3259 Wormholes【Bellman-Ford或 SPFA判断是否有负环 】
    二叉树基础练习
  • 原文地址:https://www.cnblogs.com/lzjloveit/p/14415421.html
Copyright © 2020-2023  润新知