4

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?

Srikanth
  • 11,780
  • 23
  • 72
  • 92

4 Answers4

14

It comes from Spring Cloud Commons.

To disable discoveryComposite set property spring.cloud.discovery.client.composite-indicator.enabled=false.

Set management.health.consul.enabled=false for the other.

spencergibb
  • 24,471
  • 6
  • 69
  • 75
  • Thanks @spencergibb, `spring.cloud.discovery.client.composite-indicator.enabled=false` turned off `discoveryComposite` but surprisingly `management.health.consul.enabled=false` isn't turning off the `"consul": {}` section in `/health`. – Srikanth Jan 13 '17 at 09:11
  • It may be in a later verison of spring cloud consul. What version are you using? – spencergibb Jan 13 '17 at 18:15
  • An update on this: `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. – Srikanth Apr 05 '17 at 04:38
  • > but surprisingly `management.health.consul.enabled=false` isn't turning off the "consul": {} section in `/health`. It is actually disabled by adding config param into `bootstrap.xml` – Roman Sinyakov Jan 18 '18 at 10:16
3

Disabling the composite output in SpringBoot 2.3.x

  • Just use the following key:
spring:
  cloud:
    discovery:
      client:
        composite-indicator:
          enabled: false
  • After that, the output of the discovery was not printed in the status of the healthcheck
Marcello DeSales
  • 21,361
  • 14
  • 77
  • 80
2

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.

Srikanth
  • 11,780
  • 23
  • 72
  • 92
2

In my case, setting either spring.cloud.discovery.client.health-indicator.enabled: false or spring.cloud.discovery.client.composite-indicator.enabled: false worked

devatherock
  • 2,423
  • 1
  • 8
  • 23