Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

Management endpoints and /health

When an application runs on a server, other programs watch it: a load balancer, Kubernetes, a monitoring system. They need to find out quickly whether the application is alive and whether the database is reachable. For this Micronaut offers management endpoints: ready-made addresses such as /health and /info. You do not write them; you just add the module.

Adding the module

The generator feature is called management. A single dependency in pom.xml is enough:

<!-- pom.xml -->
<dependency>
  <groupId>io.micronaut</groupId>
  <artifactId>micronaut-management</artifactId>
  <scope>compile</scope>
</dependency>

It needs no annotation processor.

The health check

curl -i http://localhost:8080/health
HTTP/1.1 200 Ok
content-type: application/json
 
{"status":"UP"}

UP means everything is fine. If some check fails, the status becomes DOWN and the response code becomes 503: that is how a load balancer knows not to send requests to this instance. An anonymous client sees only the overall result. A logged-in user sees the details:

curl -u anna:changeme http://localhost:8080/health
{"name":"blog","status":"UP","details":{"diskSpace":{"name":"blog","status":"UP","details":{"total":161750183936,"free":8383062016,"threshold":10485760}},"jdbc":{"name":"blog","status":"UP","details":{"jdbc:h2:mem:devDb":{"name":"blog","status":"UP","details":{"database":"H2","version":"2.5.250 (2026-08-29)"}}}},...}}

The response is shortened. Micronaut checks the disk space, the database connection through jdbc and deadlocked threads by itself. Who sees the details is controlled by the endpoints.health.details-visible setting (ANONYMOUS, AUTHENTICATED or NEVER).

Application details

/info returns whatever you put into the settings under the info prefix:

# src/main/resources/application.properties
endpoints.info.sensitive=false
info.blog.name=My blog
info.blog.version=1.0
curl http://localhost:8080/info
{"blog":{"version":"1.0","name":"My blog"}}

The line endpoints.info.sensitive=false makes /info open without logging in.

Built-in endpoints

AddressWhat it showsSensitive
/healthApplication statusno
/infoDetails from the info.* settingsyes
/beansAll beans in the contextyes
/routesAll routesyes
/loggersLog levels, which can be changedyes
/threaddumpJVM threadsyes

Sensitive endpoints can reveal how the application is built, so they are closed unless you configure them.

Common mistake

With Micronaut Security added, even an administrator gets a 500 response on /beans or /routes, and the log says:

ERROR i.m.http.server.RouteExecutor - Unexpected error occurred: For security purposes, sensitive endpoints are disabled
until you supply your own replacement for SensitiveEndpointRule::checkSensitiveAuthenticated

This is not a bug but a safeguard: Micronaut does not know which users can be trusted with sensitive data. Either leave these endpoints off, open the one you need with endpoints.<name>.sensitive=false, or write a bean with @Replaces(SensitiveEndpointRule.class); Micronaut prints an example of such a class right in the log.

Thanks for reading!

Donate to the site — we work hard for you.