zoukankan      html  css  js  c++  java
  • springboot2.x下actuator模块

    一、简介
        spring-boot-starter-actuator模块是一个spring提供的监控模块。我们在开运行发过程中,需要实时和定时监控服务的各项状态和可用性。Spring Boot的spring-boot-starter-actuator 模块(健康监控)功能提供了很多监控所需的接口,可以对应用系统进行配置查看、相关功能统计等。
    二、实现
        在maven的pom中引入:
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    如果使用HTTP调用的方式,还需要这个依赖:
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    三、配置
        1、health:配置
    spring:
      application:
        name: spring-cloud-consul-consumer
    server:
      port: 8803
     
    management: 
      server: 
        port: 54001  #如果不配置,默认与服务端口一致
      health:
        db:
          enabled: true
        mail:
          enabled: true
      endpoint:
        env:
          enabled: true
      endpoints:
        web:
          exposure:
            include: "*"

     访问:http://localhost:54001/health 这是springboot1.x的访问

    springboot2.x 后 http://localhost:54001/actuator/health

    结果:

    2、info:配置

    info: 
      app:
        name: "@project.name@" #从pom.xml中获取
        description: "@project.description@"
        version: "@project.version@"
        spring-boot-version: "@project.parent.version@"

    访问:http://localhost:54001/actuator/info

    {"app":{"name":"demo","description":"Demo project for Spring Boot","version":"0.0.1-SNAPSHOT","spring-boot-version":"2.1.0.RELEASE"}}

     更多端点访问,可以访问:http://localhost:54001/actuator查看。

    {"_links":{"self":{"href":"http://localhost:54001/actuator","templated":false},

    "archaius":{"href":"http://localhost:54001/actuator/archaius","templated":false},

    "auditevents":{"href":"http://localhost:54001/actuator/auditevents","templated":false},

    "beans":{"href":"http://localhost:54001/actuator/beans","templated":false},

    "caches-cache":{"href":"http://localhost:54001/actuator/caches/{cache}","templated":true},

    "caches":{"href":"http://localhost:54001/actuator/caches","templated":false},

    "health":{"href":"http://localhost:54001/actuator/health","templated":false},

    "health-component":{"href":"http://localhost:54001/actuator/health/{component}","templated":true},

    "health-component-instance":{"href":"http://localhost:54001/actuator/health/{component}/{instance}","templated":true},

    "conditions":{"href":"http://localhost:54001/actuator/conditions","templated":false},

    "configprops":{"href":"http://localhost:54001/actuator/configprops","templated":false},
    "env":{"href":"http://localhost:54001/actuator/env","templated":false},
    "env-toMatch":{"href":"http://localhost:54001/actuator/env/{toMatch}","templated":true},

    "info":{"href":"http://localhost:54001/actuator/info","templated":false},
    "loggers":{"href":"http://localhost:54001/actuator/loggers","templated":false},

    "loggers-name":{"href":"http://localhost:54001/actuator/loggers/{name}","templated":true},
    "heapdump":{"href":"http://localhost:54001/actuator/heapdump","templated":false},

    "threaddump":{"href":"http://localhost:54001/actuator/threaddump","templated":false},
    "metrics":{"href":"http://localhost:54001/actuator/metrics","templated":false},

    "metrics-requiredMetricName":{"href":"http://localhost:54001/actuator/metrics/{requiredMetricName}","templated":true},

    "scheduledtasks":{"href":"http://localhost:54001/actuator/scheduledtasks","templated":false},
    "httptrace":{"href":"http://localhost:54001/actuator/httptrace","templated":false},

    "mappings":{"href":"http://localhost:54001/actuator/mappings","templated":false},

    "refresh":{"href":"http://localhost:54001/actuator/refresh","templated":false},

    "features":{"href":"http://localhost:54001/actuator/features","templated":false},

    "service-registry":{"href":"http://localhost:54001/actuator/service-registry","templated":false},

    "consul":{"href":"http://localhost:54001/actuator/consul","templated":false}}}

    更多详细内容参考:https://blog.csdn.net/Dreamhai/article/details/81077903

  • 相关阅读:
    angular入门学习文档之一
    将SDL程序变成网页(使用emscripten)
    Nim使用OpenGL
    C++移动操作,RVO和NRVO
    从零开始制作一个粒子系统
    cocos2d-x学习之路(一)——安装cocos2d-x
    堆排序
    开发zeroc ice应用入门(java开发ice应用,python开发ice应用,java与python结合开发ice服务)
    eclipse自动提示设置以及问题:去除变量自动提示(图文详解)
    ubuntu安装新版QQ
  • 原文地址:https://www.cnblogs.com/muxi0407/p/11790832.html
Copyright © 2011-2022 走看看