Search code examples
spring-bootspring-cloudspring-boot-actuatorspring-cloud-consul

The /health endpoint of my Spring Boot app is emitting all info about the Consul server running on the same machine. How to disable this?


I've the /health endpoint enabled, but I just don't want it to list all services monitored by Consul on the same machine.

This is my application.properties:

# Enable just the health endpoint.
endpoints.health.enabled=true

# Disable all default endpoints and Spring Cloud endpoints.
endpoints.enabled=false
endpoints.consul.enabled=false
endpoints.pause.enabled=false
endpoints.resume.enabled=false
endpoints.refresh.enabled=false
endpoints.restart.enabled=false
endpoints.shutdown.enabled=false
endpoints.env.enabled=false

management.health.db.enabled=false
management.health.diskspace.enabled=false
management.health.defaults.enabled=false

... and this is what /health is currently emitting:

$ curl -o- http://localhost:8080/health | python -m json.tool
{
    "consul": {
        "advertiseAddress": "10.10.10.10", 
        "bindAddress": "10.10.10.10", 
        "clientAddress": "127.0.0.1", 
        "datacenter": "DC", 
        "domain": "consul.", 
        "nodeName": "mynode", 
        "services": {
            "myservice1": [
                "tag1"
            ], 
            "myservice2": [
                "tag1", 
                "tag2"
            ]
        }, 
        "status": "UP"
    }, 
    "description": "Spring Cloud Consul Discovery Client", 
    "discoveryComposite": {
        "description": "Spring Cloud Consul Discovery Client", 
        "discoveryClient": {
            "description": "Spring Cloud Consul Discovery Client", 
            "services": [
                "myservice1",
                "myservice2"
            ], 
            "status": "UP"
        }, 
        "status": "UP"
    }, 
    "status": "UP"
}

I don't mind the "description": "Spring Cloud Consul Discovery Client" but the rest of the stuff under "consul" and "discoveryComposite" is something I don't want to expose for /health.

What could be adding these info here to this endpoint?


Solution

  • Answering my own question for anyone else who might be seeing the same issue: management.security.enabled=false was being set in one of the Spring profiles during application startup that I didn't notice. According to the documentation here: http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-monitoring.html#production-ready-health-access-restrictions I need to set endpoints.health.sensitive=true to report just the status. Adding this token fixed the issue.