3

I'm using the following Kafka container (as a part of docker-compose.yml)

  broker:
    image: confluentinc/cp-kafka:6.0.1
    hostname: broker
    container_name: broker
    depends_on:
      - zookeeper
    ports:
      - "29092:29092"
      - "9092:9092"
      - "9101:9101"
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_JMX_PORT: 9101
      KAFKA_JMX_HOSTNAME: localhost
      EXTRA_ARGS: '-javaagent:/usr/share/jmx-exporter/jmx_prometheus_javaagent-0.15.0.jar=7101:/etc/jmx-exporter/config.yml'
    volumes:
      - ./kafka/data:/var/lib/kafka/data
      - ./jmx-exporter/kafka-2_0_0.yml:/etc/jmx_exporter/config.yml
      - ./jmx-exporter/jar:/usr/share/jmx_exporter/

Jmx exporter causes container to crash, here are the logs:

===> Launching ... 
===> Launching kafka ... 
Error occurred during initialization of VM
Error opening zip file or JAR manifest missing : /usr/share/jmx-exporter/jmx_prometheus_javaagent-0.15.0.jar
agent library failed to init: instrument

I verified jmx exporter jar and it's config to be available inside container.

jmx_prometheus_javaagent-0.15.0.jar has been downloaded from here: github.com/prometheus/jmx_exporter

Any ideas?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Rodion Altshuler
  • 1,713
  • 1
  • 15
  • 31

2 Answers2

1

I had a very similar problem with a different Confluent Docker image, and realized that the error message from the JVM is misleading: in my case, the issue was actually one of permissions (the jar was there in the image, but just not readable by the user that the JVM was running as).

I was using the Dockerfile ADD directive with a URL to fetch the Prometheus jmx_exporter jar as part of the image build phase, but failed to realize that since the Confluent images run as a user called appuser, the resulting file within the container wouldn't be readable by that user.

In my case, the solution was to use the --chown flag to the ADD directive. Since you're mounting the exporter jar via a volume, I'm guessing that there's something similar going on.

grumbler
  • 886
  • 9
  • 20
0
/usr/share/jmx-exporter/jmx_prometheus_javaagent-0.15.0.jar=7101:/etc/jmx-exporter/config.yml'

In here that 7101 signifies the port. According to this the hmx port is 7101, but in the later config you have mentioned the port to be 9101.

Try changing that. I hope it was helpful.

Supreet Singh
  • 87
  • 1
  • 8
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 11 '21 at 07:57