Reputation: 1764
Currently spring boot actuator metrics returns metrics for various system parameters. I want to turn on some selected metrics parameters, for example; show only metrics related to memory and processor. I had several attempts to figure out solution but nothing worked for me. I see SystemPublicMetrics
registers all basic system metrics and management system matrics, how can I turn on only few of them?
Required output:
{
"mem": 495055,
"mem.free": 372397,
"processors": 4
}
Upvotes: 3
Views: 3850
Reputation: 41
You can do this by disabling CacheMetricsAutoConfiguration of spring boot auto configuration at start-up by adding metrics class to exclusion list.
For instance to disable cache metrics add following at startup:
import org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsAutoConfiguration;
@EnableAutoConfiguration(exclude = {CacheMetricsAutoConfiguration.class}) public class Application extends SpringBootServletInitializer { ... ...
This should help..
Upvotes: 2
Reputation: 2872
You will not be able to disable specific metrics. Rather, you will be able to enable/disable at endpoints only.
Following are the flags that you can add in application.properties to enable/disable specific endpoints in Spring Boot Actuator
endpoints.autoconfig.enabled=false
endpoints.beans.enabled=false
endpoints.configprops.enabled=false
endpoints.dump.enabled=false
endpoints.env.enabled=false
endpoints.health.enabled=true
endpoints.info.enabled=true
endpoints.metrics.enabled=false
endpoints.mappings.enabled=false
endpoints.shutdown.enabled=false
endpoints.trace.enabled=false
Upvotes: 1