jmx_exporter icon indicating copy to clipboard operation
jmx_exporter copied to clipboard

Allow blacklisting of jvm metrics

Open udesaiitrs opened this issue 3 years ago • 4 comments

Hello, I was hoping to understand why certain JVM metrics (java.lang:*) cannot be blacklisted/removed via configuration of the javaagent? The exporter should include these as there can be instances like in our case where we do not want the duplicate JVM metrics because they are collected by another application.

For example, the following should work but doesn't I believe:

blacklistObjectNames: 
  - "java.nio:*"
  - "java.lang:*"

udesaiitrs avatar Mar 25 '22 16:03 udesaiitrs

I have found how there are many default exports registered: https://github.com/prometheus/jmx_exporter/blob/ca972bfe693cca03d3a0fac802968e33828a1dd9/jmx_prometheus_javaagent_java6/src/main/java/io/prometheus/jmx/JavaAgent.java#L30

I feel as though it would be a good option to implement a configuration option to allow these to be turned off (on by default), especially with the growing scenarios such as Kubernetes environments where all the extra metrics may not be needed.

Is this something that sounds plausible?

udesaiitrs avatar Mar 25 '22 20:03 udesaiitrs

will appreciate such feature to, to not spawn our Prom cluster with the jvm container metrics

gmariette avatar Nov 09 '22 21:11 gmariette

This sounds like a great enhancement. It would require changes to ...

https://github.com/prometheus/client_java/blob/main/simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/DefaultExports.java

... to allow unregistering the collectors to support dynamic configuration reloading.

dhoard avatar Jul 10 '23 03:07 dhoard

Or as an alternative not use DefaultExports.initialize(); but add configuration-specific options and call the underlying exports classes directly.

new BufferPoolsExports().register(registry);
new ClassLoadingExports().register(registry);
new CompilationExports().register(registry);
new GarbageCollectorExports().register(registry);
new MemoryAllocationExports().register(registry);
new MemoryPoolsExports().register(registry);
new StandardExports().register(registry);
new ThreadExports().register(registry);
new VersionInfoExports().register(registry);

dhoard avatar Aug 12 '23 04:08 dhoard