0

I want to keep collecting jvm and other metrics, but just don't want to push all of them to cloudwatch or prometheus (or anything else).

If I do like this

@Bean
MeterRegistryCustomizer<MeterRegistry> customizer() {
    return (registry) -> registry.config()
        .meterFilter(MeterFilter.denyNameStartsWith("jvm"));
}

it stops publishing to cloudwatch but at the same time, the metrics are gone from /actuator/metrics/ as well.

Is there anyway I can keep them accessible under /actuator/metrics/ but stop pushing those to remote metrics collector ?

gaganbm
  • 2,663
  • 3
  • 24
  • 36

1 Answers1

1

If you are looking for how to expose Spring Boot Actuator metrics endpoint but not to publish metrics to any remote meter registry like Prometheus, just adding the org.springframework.boot:spring-boot-starter-actuator without any monitoring system-specific dependency like io.micrometer:micrometer-registry-prometheus should work. This is a working sample.

However, based on the project owner's comment, the endpoint is intended for a diagnostic purpose only, so you should use one of monitoring system-specific meter registries for monitoring purposes as follows:

The actuator endpoint is at best a toy, a diagnostic tool. The real heavy lifting of structuring the data for publishing happens in each registry implementation.


UPDATED:

Based on your comment, if I understand correctly, you want to expose all metrics on the metrics endpoint but publish some of them to a remote meter registry.

For doing so, you can add a SimpleMeterRegistry for the metrics endpoint and add a MeterRegistryCustomizer for the remote meter registry to add some MeterFilter.

See this commit and this branch for a Prometheus example.

Johnny Lim
  • 5,623
  • 8
  • 38
  • 53
  • Thats not what I want. I want to publish to remote meter registry, but only some of them. Like all non-jvm metrics. But when I add that meter filter, all jvm metrics are removed from being published, as well as removed from the actuator endpoint. – gaganbm Jul 30 '18 at 12:02