Search code examples
wildfly

WildFly Full 18.0.1.Final - how to disable smallrye metrics?


Im trying to completely disable metrics exposed on http://localhost:port/metrics, like:

# HELP base_cpu_processCpuLoad Displays the "recent cpu usage" for the Java     
Virtual Machine process.

# TYPE base_cpu_processCpuLoad gauge
base_cpu_processCpuLoad 0.44242270160615144

After doing research I've found this line in ../configuration/standalone.xml:

<subsystem xmlns="urn:wildfly:microprofile-metrics-smallrye:2.0" security-enabled="false" exposed-subsystems="none" prefix="${wildfly.metrics.prefix:wildfly}"/>

Setting exposed-subsystems to "none" or leaving it blank should disable the metrics, but it's still exposed, just less data. I need to remove it completely. Is there any other way?


Solution

  • You should just be able to remove the subsystem. This could be done with a management API or endpoint. The simplest would probably be with CLI. The CLI command would look like the following:

    /subsystem=microprofile-metrics-smallrye:remove
    

    You could do this with offline CLI too. Just start jboss-cli, $JBOSS_HOME/bin/jboss-cli.sh, then start the embedded server.

    embed-server
    /subsystem=microprofile-metrics-smallrye:remove
    stop-embedded-server
    exit
    

    This could also be done with the wildfly-maven-plugin if you'd like to do this as part of a build.