I woud like to disable all actuator endpoints except for the health endpoint. All docs describe how to achieve this in the resource properties:
endpoints.enabled=false
endpoints.health.enabled=true
but I have always preferred to use inline java configuration. Could someone please explain where in the application I can configure the same?
Looking at org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration, the endpoints are provided when the beans are missing. One option would be to provide them in your own configuration class. All endpoints have the field enabled. You could provide all of them, setting enabled on false, except for the one you need.
@Configuration
public class ActuatorConfiguration {
@Autowired(required = false)
private Collection<PublicMetrics> publicMetrics;
@Bean
public MetricsEndpoint metricsEndpoint() {
List<PublicMetrics> publicMetrics = new ArrayList<>();
if (this.publicMetrics != null) {
publicMetrics.addAll(this.publicMetrics);
}
Collections.sort(publicMetrics,AnnotationAwareOrderComparator.INSTANCE);
MetricsEndpoint metricsEndpoint = new MetricsEndpoint(publicMetrics);
metricsEndpoint.setEnabled(false);
return metricsEndpoint;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With