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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.