Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter Spring boot actuator metrics?

Spring boot actuator metrics (/actuator/metrics) comes with many default metrics. Some of them are:

"jvm.memory.max",
"jvm.threads.states",
"process.files.max",
"jvm.gc.memory.promoted",
"tomcat.servlet.error",
"system.load.average.1m",
"jvm.memory.used",
"jvm.gc.max.data.size",
"jvm.memory.committed",
"http.server.requests",
"system.cpu.count",
"logback.events",
"tomcat.global.sent",
...

Is it possible to expose only few of them? (i.e. filtering them or better yet, telling Spring boot not to collect them at all?)

like image 446
yaseco Avatar asked Sep 20 '25 01:09

yaseco


1 Answers

You can use management.metrics.enable.* properties to control the metrics that are enabled and bound to the meter registry. Where a metric's name is . separated, you can disable multiple metrics with a single property. For example, to disable all jvm properties you can use the following property:

management.metrics.enable.jvm=false

Where there are multiple properties that match the same metric, the most-specific wins. For example, to disable all jvm metrics other than jvm.memory.max, you can use the following properties:

management.metrics.enable.jvm=false
management.metrics.enable.jvm.memory.max=true

You can use all to match all metrics. For example, to disable all metrics other than jvm.memory metrics, you can use the following properties:

management.metrics.enable.all=false
management.metrics.enable.jvm.memory=true
like image 83
Andy Wilkinson Avatar answered Sep 21 '25 20:09

Andy Wilkinson