Video in progress

Strong Junior 🌱 Spring

/actuator/health shows DOWN, but the application's API works. What do you check?

Health is the sum of several indicators: db, diskSpace, redis, mail and so on. If one is DOWN, the overall status is DOWN too. You turn on the details and find which component is at fault.

📖 Answer

The first step is to look at the details:

management:
  endpoint:
    health:
      show-details: always   # only on the internal network, or when-authorized

Now the response looks like this:

{
  "status": "DOWN",
  "components": {
    "db":        { "status": "UP" },
    "diskSpace": { "status": "UP" },
    "mail":      { "status": "DOWN", "details": { "error": "Connection refused" } },
    "redis":     { "status": "UP" }
  }
}

In this example the SMTP server can't be reached. The API works because requests don't touch the mail server.

Why this is bad: Kubernetes or a load balancer sends traffic based on health. If a secondary system (mail, an external service) goes down, the whole application can be pulled out of rotation or restarted, and a small problem turns into a big incident.

What you can do:

  • turn off an unneeded indicator: management.health.mail.enabled=false;
  • separate the liveness/readiness groups, and add to readiness only what the application can't work without (say, the main database);
  • keep your own HealthIndicator fast and don't hammer the external system: health gets called every few seconds.