Couldn't able to set up the JMX exporter to scrape the JVM metrics.

218 views
Skip to first unread message

Manikanta Gupta

unread,
Oct 9, 2019, 10:42:25 AM10/9/19
to Prometheus Users

We are trying to configure the JMX exporter on linux machines to scrape all the JVM metrics and feed those data to prometheus database and later we want to visualize those in Grafana, for that we downloaded the jar file (jmx_prometheus_javaagent-0.12.0.jar) and trying to execute it using the below command.

"java -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=7201:config.yaml -jar jmx_prometheus_javaagent-0.12.0.jar"

but we are getting below two errors

ERROR 1 :

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.io.FileNotFoundException: config.yaml (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileReader.(FileReader.java:72)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.(JmxCollector.java:74)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:29)
... 6 more
FATAL ERROR in native method: processing of -javaagent failed

Where is the config.yaml file is located?, How to download the config.yaml?, What the configurations did config.yaml contains, Please help in providing these.

Just as a work around we created an empty file with config.yaml in the current directory and executed the same command "java -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=7201:config.yaml -jar jmx_prometheus_javaagent-0.12.0.jar" then we got another error


ERROR 2 :
no main manifest attribute, in jmx_prometheus_javaagent-0.12.0.jar

Yz Xyz

unread,
Oct 9, 2019, 11:52:15 AM10/9/19
to Prometheus Users
You have to list of attributes you want to scrape for in YAML format.

Satish P

unread,
Oct 9, 2019, 4:26:49 PM10/9/19
to Prometheus Users
From the web page: https://github.com/prometheus/jmx_exporter, one should be doing 

java -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=8080:config.yaml -jar yourJar.jar

Looks like your last argument need to point to the JAVA application you are trying to Monitor.

On Wednesday, October 9, 2019 at 10:42:25 AM UTC-4, Manikanta Gupta wrote:

pranith gande

unread,
Mar 31, 2020, 10:10:07 AM3/31/20
to Prometheus Users
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.NullPointerException
        at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:25)
        ... 6 more
Hi, i am also getting same error can anyone help me out
Reply all
Reply to author
Forward
0 new messages