Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Actuator/Micrometer Metrics Disable Some

Is there a way to turn off some of the returned metric values in Actuator/Micrometer? Looking at them now I'm seeing around 1000 and would like to whittle them down to a select few say 100 to actually be sent to our registry.

like image 463
Joel Holmes Avatar asked Jan 25 '18 20:01

Joel Holmes


1 Answers

Let me elaborate on the answer posted by checketts with a few examples. You can enable/disable certain metrics in your application.yml like this:

management:
  metrics:
    enable:
      tomcat: true
      jvm: false
      process: false
      hikaricp: false
      system: false
      jdbc: false
      http: false
      logback: true

Or in code by defining a MeterFilter bean:

@Bean
public MeterFilter meterFilter() {
    return new MeterFilter() {
        @Override
        public MeterFilterReply accept(Meter.Id id) {
            if(id.getName().startsWith("tomcat.")) {
                return MeterFilterReply.DENY;
            }
            if(id.getName().startsWith("jvm.")) {
                return MeterFilterReply.DENY;
            }
            if(id.getName().startsWith("process.")) {
                return MeterFilterReply.DENY;
            }
            if(id.getName().startsWith("system.")) {
                return MeterFilterReply.DENY;
            }
            return MeterFilterReply.NEUTRAL;
        }
    };
}
like image 168
Mzzl Avatar answered Nov 09 '22 14:11

Mzzl