在Consul中,可以查看SpringBoot应用程序中配置的运行状况。
有谁知道让我知道通过Actuator可以在Consul中看到其他指标(健康除外)?
或者我们可以让Consul提取/调用服务的任何服务/ URL,以便可以在领事中查看响应吗?
答案 0 :(得分:1)
Consul正在使用健康端点来确定服务实例是否健康。如果您需要考虑某些自定义指标的自定义运行状况,则应实现HealthIndicator接口。
您可以通过在application.properties
中设置management.security.enabled=false
来在health api中公开更多信息
在这种情况下,您会在服务的consul admin 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注册(请参阅下面的日志片段):
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}