prometheus / jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Apache License 2.0
3.01k stars 1.2k forks source link

The metric jvm_memory_used_bytes transitioned to jvm_memory_bytes_used starting from a certain version of jmx_exporter? #909

Closed YANGJINJUE closed 2 days ago

YANGJINJUE commented 7 months ago

use version: 0.16.0

YANGJINJUE commented 7 months ago

use version: 0.16.0。jdk21. The presence of -1.0 in the expression jvm_memory_bytes_max{area="nonheap",} -1.0. why?

dhoard commented 7 months ago

@YANGJINJUE 0.16.0 shipped with the Prometheus client_java 0.11.0 library, which may have introduced the change.

I suggest you upgrade to the latest version 0.20.0 and adjust your dashboards.

YANGJINJUE commented 7 months ago

@YANGJINJUE 0.16.0 shipped with the Prometheus client_java 0.11.0 library, which may have introduced the change.

I suggest you upgrade to the latest version 0.20.0 and adjust your dashboards.

use: jmx_prometheus_javaagent-0.20.0.jar use: jdk21, error: Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:560) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:572) Caused by: java.lang.NoSuchMethodError: 'io.prometheus.jmx.shaded.io.prometheus.client.Collector io.prometheus.jmx.BuildInfoCollector.register()' at io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:54) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ... 3 more java.lang.instrument ASSERTION FAILED : "!errorOutstanding" with message Outstanding error when calling method in invokeJavaAgentMainMethod at open/src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 627 java.lang.instrument ASSERTION FAILED : "success" with message invokeJavaAgentMainMethod failed at open/src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 466 java.lang.instrument ASSERTION FAILED : "result" with message agent load/premain call failed at open/src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 429 FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.dylib+0x53ecac] jni_FatalError+0xdc V [libjvm.dylib+0x6ae64c] JvmtiExport::post_vm_initialized()+0x2dc V [libjvm.dylib+0x9bd22c] Threads::create_vm(JavaVMInitArgs, bool)+0x79c V [libjvm.dylib+0x55b994] JNI_CreateJavaVM+0x68 C [libjli.dylib+0xa9f4] JavaMain+0x104 C [libjli.dylib+0xd8d0] ThreadJavaMain+0xc C [libsystem_pthread.dylib+0x7034] _pthread_start+0x88

aestebangarcianavas commented 6 months ago

We are also using 0.20.0 and it doesn't work with Java 21. There is no update of this issue since one month. Are you planing to fix it?

dhoard commented 6 months ago

@YANGJINJUE

Caused by: java.lang.NoSuchMethodError: 'io.prometheus.jmx.shaded.io.prometheus.client.Collector io.prometheus.jmx.BuildInfoCollector.register()'

typically happens if you have multiple versions of the jar somewhere in your classpath. The JVM is loading classes from different jars that mismatched/out of sync.

dhoard commented 6 months ago

@aestebangarcianavas can please elaborate? The code has been tested and works on...

brandizzi commented 2 days ago

For those confused by this: the Prometeus client_java library changed the name of the metrics from its 0.16 version to 1.0 version: https://github.com/prometheus/client_java/blob/main/docs/content/migration/simpleclient.md#jvm-metrics. You can consult the list of the changed names in the link above.