First of all I'd like tell that sidgate's answer is correct.
But maybe somebody need to enable all metrics or choose different set of metrics.
You still can use spring-boot-starter-actuator
instead of spring-boot-actuator
For enabling all metrics
@org.springframework.context.annotation.Configuration
@org.springframework.boot.autoconfigure.EnableAutoConfiguration
@org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration
public class MyApplicationContext {
}
where @EnableAutoConfiguration
org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.CacheStatisticsAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.EndpointMBeanExportAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.InfoContributorAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.JolokiaAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.MetricsDropwizardAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.MetricsChannelAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.MetricExportAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.TraceRepositoryAutoConfiguration,
org.springframework.boot.actuate.autoconfigure.TraceWebFilterAutoConfiguration.class
and @ManagementContextConfiguration
org.springframework.boot.actuate.autoconfigure.EndpointWebMvcManagementContextConfiguration,
org.springframework.boot.actuate.autoconfigure.EndpointWebMvcHypermediaManagementContextConfiguration
enables Spring Boot Configurations
For enabling certain management endpoints you could import endpoint's configurations directly as sidgate's already explained
@Configuration
@Import({
org.springframework.boot.actuate.autoconfigure.AuditAutoConfiguration.class,
org.springframework.boot.actuate.autoconfigure.CacheStatisticsAutoConfiguration.class,
...
})
public class MyApplicationContext {
}
P.S. Of course Spring Application Context and Properties initialization could be configured as always via annotations or xml configuration.
PublicMetricsAutoConfiguration.class
to get jvm/threads metrics available at /metrics endpoint – Scheider