I have spring boot 2 REST application, with spring actuator enabled. by default spring generates a number of metrics (jvm, cpu, memory, etc) in /metrics endpoint. Apart from this I have used Micrometer APIs to create custom metrics. So far its been working really well.
Now, I have a requirement to generate only my custom metrics, but disable all the default metrics that spring provides. Note that I do not want to disable /metrics endpoint, but I want to disable only the default metrics.
Is this possible directly/indirectly now?
Thanks for any opinions and suggestion!
@SpringBootApplication(
exclude = {
CompositeMeterRegistryAutoConfiguration.class,
DataSourcePoolMetricsAutoConfiguration.class,
TomcatMetricsAutoConfiguration.class,
SimpleMetricsExportAutoConfiguration.class,
SystemMetricsAutoConfiguration.class
}
)
You need to exclude all the metrics auto configuration classes which are responsible for the default metrics in Spring Boot.
You can find all the metrics auto configuration classes here:
https://github.com/spring-projects/spring-boot/blob/v2.1.1.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories
Like most things in Spring Boot, the default metrics are configured via various auto-configuration classes. To disable the default metrics, exclude their auto-configuration classes using the exclude attribute on @SpringBootApplication. To see what auto-configurations are involved, you can launch your app with --debug or take a look at the source code.
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