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

23,005

Solution 1

By default Spring sets the below property to never. To be able to see full health details add the below property to your application.properties.

management.endpoint.health.show-details=always

Solution 2

In cases if you are using spring security, then by default security is enabled for actuator endpoints, disable it in your yml file -

management:
    security:
           enabled: false

Solution 3

From the spring-boot documentation:

45.6 Security with HealthIndicators

Information returned by HealthIndicators is often somewhat sensitive in nature. For example, you probably don’t want to publish details of your database server to the world. For this reason, by default, only the health status is exposed over an unauthenticated HTTP connection. If you are happy for complete health information to always be exposed you can set endpoints.health.sensitive to false. Health responses are also cached to prevent “denial of service” attacks. Use the endpoints.health.time-to-live property if you want to change the default cache period of 1000 milliseconds.

Make sure to have following properties set.

endpoints.health.sensitive=true # Mark if the endpoint exposes sensitive 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.

Solution 4

IIUC, the aggregate health is shown under /health, at least (IIUC) for springboot2. Meaning, that even if you have everything configured just right, only one line will be shown.

UPDATE: and if this is not what you need, you have to specifically ask to see details. Check these settings:

management.endpoint.health.show-details=when-authorized
management.endpoint.health.roles=ADMIN
Share:
23,005
jeremy simon
Author by

jeremy simon

Updated on July 09, 2022

Comments

  • jeremy simon
    jeremy simon over 1 year

    I cannot get database information or filesystem information to show up on the /health endpoint. I only can get:

    {
      "status": "UP"
    }
    

    Details about my setup and configuration: - Spring Boot 1.3.3 - Running the WAR on JBoss EAP 6.4 - Datasource is a JNDI resource. - Oracle is the database

    spring:
      datasource:
        # Must match the datasource name in JBoss standalone.xml
        jndi-name: java:jboss/beautiful-ds
        driver-class-name: oracle.jdbc.driver.OracleDriver
      jpa:
        properties:
          # escapes reserved words used as column names (if any)
          globally_quoted_identifiers: true
        show-sql: true
        hibernate:
            naming_strategy: org.hibernate.cfg.EJB3NamingStrategy
    
    server:
      servlet-path: /*
    
    management:
      health:
        diskspace:
          enabled: true
        db:
          enabled: true
    endpoints.health.sensitive: false
    

    One thing i found on /configprops is this, which I'm not sure whether it is related:

      "spring.datasource.CONFIGURATION_PROPERTIES": {
        "prefix": "spring.datasource",
        "properties": {
          "error": "Cannot serialize 'spring.datasource'"
        }
    

    I had tried adding "driver-class-name: oracle.jdbc.driver.OracleDriver" thinking it maybe needed more details, but that didn't change the situation.

    so yeah, what gives? I made a vanilla example project which at least shows the filesystem stuff out the gate, so not sure why either don't want to show in my "real" app. Tell me your great and wise answers! :)

  • jeremy simon
    jeremy simon over 7 years
    I appreciate the answer, but believe it or not, I am able to toggle that value without issue using that properties syntax. Changing that line to YAML format is behaving the same. No new results on /heath.
  • dunni
    dunni over 7 years
    Do you have security enabled?
  • jeremy simon
    jeremy simon over 7 years
    I'm using the keycloak adaptor for spring boot. I can get to all my endpoints fine.
  • Ninja Code Monkey
    Ninja Code Monkey about 7 years
    I could see my endpoints, but to get details, still needed: management.security.enabled=false
  • sunleo
    sunleo over 6 years
    This is not the answer, last line in the code and proposed one both will work in same way.
  • volkovs
    volkovs over 5 years
    In the beginning I thought there is a typo, since other properties start with management.endpointS. But you are right. Other useful value of the property is when-authorized: docs.spring.io/spring-boot/docs/current/reference/html/…
  • volkovs
    volkovs over 5 years
    IDEA suggests using property value when_authorized which works as well.