2

I'm currently triying to expose Kafka Connect Workers JMX :

Using this docker image :

FROM cnfldemos/cp-server-connect-datagen:0.5.3-7.1.0
ADD --chown=1000:1000 exporterConfig.yml /opt/prometheus-exporter/prom-jmx-agent-config.yml
ADD --chown=1000:1000 jmx_prometheus_javaagent-0.17.0.jar /opt/prometheus-exporter/agent.jar

The JMX Exporter version is the last one from 0

Here is the result logs when the connect worker is starting :

PS D:\env\confluent-platform> docker logs connect -f
===> User
uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
===> Configuring ...
===> Running preflight checks ...
===> Check if Kafka is healthy ...
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.NoSuchFieldError: UNKNOWN
        at io.prometheus.jmx.JmxCollector$Rule.<init>(JmxCollector.java:57)
        at io.prometheus.jmx.JmxCollector.loadConfig(JmxCollector.java:214)
        at io.prometheus.jmx.JmxCollector.<init>(JmxCollector.java:91)
        at io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:29)
        ... 6 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed

This java.lang.NoSuchFieldError make me think about dependency conflict issue,

I got through the code of JMX Exporter & its simpleclient dependency

indeed the UNKNOWN Type enum value from simpleclient dependency in Collector.java class only appeared after version 10, and 14 is the dependency version number in JMX Exporter.

But i took the source code of the cnfldemos/cp-server-connect-datagen and i was not able to find any reference to this dependency package.

Any advice welcome !

Promila Ghosh
  • 389
  • 4
  • 12
Sid
  • 331
  • 2
  • 10

1 Answers1

1

If you check the source code of the confluent kafka-connect images

You will notice that, you have to set the following environment variables to enable JMX

  1. KAFKA_JMX_OPTS
  2. KAFKA_JMX_HOSTNAME (optional, if not specified it will take the current hostname)
  3. KAFKA_JMX_PORT

The issue you are facing is because when you specify the KAFKA_JMX_OPTS, by default the jmx authentication is enabled. To disable it use this flag -Dcom.sun.management.jmxremote.authenticate=false

I resolved this issue with following configuration:

  KAFKA_JMX_OPTS: -javaagent:/usr/share/java/kafka-connect-sample/jmx_prometheus_javaagent-0.17.2.jar=8080:/usr/share/java/kafka-connect-sample/prometheus-kafka-connect.yml -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
vishal
  • 21
  • 1