How to specify a meter filter to spring actuator metrics endpoint?

Viewed 855

In application.properties I've added value for endpoints.metrics.path. It works, but it returns json containing lots of metrics including jvm, tomcat, logback etc., gauge and counter for every endpoint that is called during runtime.

I would like to filter that endpoint, I've added to my app spring metrics library and micrometer directly. So my current metrics libraries are:

compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'io.micrometer:micrometer-registry-prometheus:latest.release'
runtime 'io.micrometer:micrometer-spring-legacy:1.3.10'
compile 'org.springframework.metrics:spring-metrics:latest.release'

When I added following property

management.metrics.enable.jvm=false

Then I can see in Metrics.globalRegistry.getRegistries(); that it is applied, jvm metrics are not there. I also tried defining a @Bean with MeterFilters and it was called and filtered, but in both cases it seems that these filters are not applied to answer of endpoint defined in

endpoints.metrics.path

Probably source of metrics in this endpoint are not micrometer MeterRegistries, so I would like to ask is there a way to filter this endpoint or is there similar ready-to-use endpoint? My limitation is springboot 1.5

0 Answers
Related