How do I add multiple paths to management.endpoint.health.group.liveness.additional-path ?
I tried with server:/somehealth,server:/another and with server:/somehealth;server:/anotherhealth
final var app = new SpringApplication();
app.setDefaultProperties(createConfigMap());
app.run();
protected HashMap<String, Object> createConfigMap() {
var configMap = new HashMap<String, Object>(Map.ofEntries(
Map.entry("management.endpoints.web.base-path", "/"),
Map.entry("management.endpoints.web.exposure.include", "health,prometheus,info"),
Map.entry("management.endpoints.web.path-mapping.prometheus", "metrics"),
Map.entry(
"management.endpoint.health.group.readiness.additional-path", "server:/ready"),
Map.entry("management.health.probes.enabled", "true")));
for (var path: _config.getAdditionalHealthPaths().stream().map(path -> String.format("server:%s", path)).toList()) {
configMap.put("management.endpoint.health.group.liveness.additional-path", path);
}
return configMap;
}
Is there a way to add dynamically new paths to the health endpoint?
I would not like to use @RequestMapping("path") since I don't know beforehand which might be the paths to add to the liveness for example.
Do I need to write a RestController to add these new paths?
How do I add multiple paths to management.endpoint.health.group.liveness.additional-path ?
I tried with server:/somehealth,server:/another and with server:/somehealth;server:/anotherhealth
final var app = new SpringApplication();
app.setDefaultProperties(createConfigMap());
app.run();
protected HashMap<String, Object> createConfigMap() {
var configMap = new HashMap<String, Object>(Map.ofEntries(
Map.entry("management.endpoints.web.base-path", "/"),
Map.entry("management.endpoints.web.exposure.include", "health,prometheus,info"),
Map.entry("management.endpoints.web.path-mapping.prometheus", "metrics"),
Map.entry(
"management.endpoint.health.group.readiness.additional-path", "server:/ready"),
Map.entry("management.health.probes.enabled", "true")));
for (var path: _config.getAdditionalHealthPaths().stream().map(path -> String.format("server:%s", path)).toList()) {
configMap.put("management.endpoint.health.group.liveness.additional-path", path);
}
return configMap;
}
Is there a way to add dynamically new paths to the health endpoint?
I would not like to use @RequestMapping("path") since I don't know beforehand which might be the paths to add to the liveness for example.
Do I need to write a RestController to add these new paths?
This is not supported, only a single additional path is allowed.
Health groups can be made available at an additional path on either the main or management port. This is useful in cloud environments such as Kubernetes, where it is quite common to use a separate management port for the actuator endpoints for security purposes.
This property is bound to AdditionalHealthEndpointPath which accepts a single value.