无法获得spring-boot / health指示器来显示完整内容

时间:2016-11-06 18:08:14

标签: spring spring-boot

尝试获取/ health端点的完整内容。我已经设置了以下内容:

endpoints.health.sensitive=true
management.security.enabled=true

我正在成功进行身份验证(之前,首先要获得对端点的访问权限),如下面的日志片段所示:

2016-11-06 10:48:18,936 [XNIO-3 task-1]DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'endpoints.health.sensitive' in [applicationConfig: [classpath:/application.properties]] with type [String] and value 'true'
2016-11-06 10:48:19,109 [XNIO-3 task-1]DEBUG o.s.s.w.h.writers.HstsHeaderWriter - Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@4542ffee
2016-11-06 10:48:19,109 [XNIO-3 task-1]DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - SecurityContext 'org.springframework.security.core.context.SecurityContextImpl@760f603a: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@760f603a: Principal: org.springframework.security.ldap.userdetails.LdapUserDetailsImpl@375540cb: ......; Enabled: true; AccountNonExpired: true; CredentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ......; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: .....' stored to HttpSession: 'io.undertow.servlet.spec.HttpSessionImpl@768a4e99
2016-11-06 10:48:19,148 [XNIO-3 task-1]DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Written [UP {}] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@eae8a50]

但是最后一行可以看到我只显示了“非敏感”信息(如果我将两个spring-boot属性设置为false,应用程序中会出现数据库连接。 / p>

根据我的阅读,应显示db状态。

我错过了什么?

3 个答案:

答案 0 :(得分:0)

Spring Boot Actuator /health endpoint does not show database or file system information

可能重复

我认为您需要默认启用数据库运行状况检查

management.health.db.enabled=true # Enable database health check.
management.health.defaults.enabled=true # Enable default health indicators.
management.health.diskspace.enabled=true # Enable disk space health check.

Spring Boot

还为各种后端实现提供了自动配置的运行状况指示器

请参阅:http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#_auto_configured_healthindicators

希望它有所帮助。

答案 1 :(得分:0)

在HealthMvcEndpoint(https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java)中放置一个断点,在调试中,您将能够根据暴露健康信息的基础组件和安全配置(exposeHealthDetails方法)了解健康响应的构建方式。

答案 2 :(得分:0)

在属性文件中添加以下属性以解决问题:

management.health.db.enabled=true