Issue
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?
Solution
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;
}
}
Answered By - Qkyrie
Answer Checked By - Willingham (JavaFixing Volunteer)