【问题标题】:Springboot Actuator with Consul带有 Consul 的 Spring Boot 执行器
【发布时间】:2018-07-23 11:05:37
【问题描述】:

在Consul中,可以查看SpringBoot应用中配置的健康状态。

谁能知道让我知道通过 Actuator 在 Consul 中可以看到哪些其他指标(健康除外)?

或者我们可以让 Consul 拉取/调用服务的任何服务/URL,以便可以在 consul 中查看响应?

【问题讨论】:

    标签: spring-boot consul spring-boot-actuator spring-boot-configuration


    【解决方案1】:

    Consul 正在使用健康端点来确定服务实例是否健康。如果您想要考虑一些自定义指标的自定义健康状态,您应该实现 HealthIndicator 接口。

    您可以通过在 application.properties 中设置 management.security.enabled=false 在 health api 中公开更多信息

    在这种情况下,您将在您的服务的领事管理 UI 中看到类似的内容

    HTTP GET http://192.168.0.102:8080/health: 200  Output: {"description":"Composite Discovery Client","status":"UP","discoveryComposite":{"description":"Composite Discovery Client","status":"UP","discoveryClient":{"description":"Composite Discovery Client","status":"UP","services":["application","consul"]}},"diskSpace":{"status":"UP","total":499963170816,"free":341478899712,"threshold":10485760},"consul":{"status":"UP","leader":"127.0.0.1:8300","services":{"application":[],"consul":[]}},"hystrix":{"status":"UP"}}
    

    您可以将健康 URL 配置到不同的端点。例如,如果您指定spring.cloud.consul.discovery.healthCheckPath=/health2,那么您的 spring-boot 实例将使用以下 json 注册(请参阅下面的 log sn-p):

    Registering service with consul: NewService{id='application', name='application', tags=[], address='192.168.0.102', port=8080, enableTagOverride=null, check=Check{script='null', interval='10s', ttl='null', http='http://192.168.0.102:8080/health2', tcp='null', timeout='null', deregisterCriticalServiceAfter='null', tlsSkipVerify=null, status='null'}, checks=null}
    

    【讨论】:

    • 谢谢亚历克斯。但是,我正在寻找除健康以外的任何其他信息。
    • 您需要查看 /metrics 端点。您可以在此处查找示例:baeldung.com/spring-boot-actuators
    猜你喜欢
    • 2021-11-12
    • 2018-08-29
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    • 2014-04-07
    • 2018-10-18
    • 2016-12-24
    • 1970-01-01
    相关资源
    最近更新 更多