使用Spring Boot Actuator 监控程序运行状态

2.X版本Spring Boot Actuator的使用

1、maven依赖

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

2、application.yml配置

server:
  port: 8762
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS
对于几个配置的说明:
management:
  endpoints:
    enabled-by-default: false # 禁用所有端点
management:
  endpoints:
    web:
      exposure:
        exclude: env # 禁用运行环境信息

3、访问 http://127.0.0.1:8762/actuator ,可以看到Actuator 端点列表

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

4、对几个端点的说明

beans,应用中beans的关系列表

health,健康指标

env,环境变量

猜你喜欢

转载自blog.csdn.net/suoyx/article/details/113823358