Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package jmx prometheus exporter to be run as a Java Agent #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sidps
Copy link

@sidps sidps commented Jun 25, 2020

This is part of addressing Yolean/kubernetes-kafka#322 (comment)

This solution involves building the javaagent jar and stashing it in a separate docker image, and may be built with docker build --target javaagent.

The image that's used for the exporter sidecar can be built with docker build --target httpserver.

@sidps
Copy link
Author

sidps commented Jun 25, 2020

I've tested that this works with docker-compose, by copying over the jar and sample config into the kafka container. The docker-compose.yaml looks something like this:

---
version: "3.7"
services:
  jmx-jar-init:
    image: <image-we-just-built>
    entrypoint:
      - /bin/bash
      - -c
      - |
        cp jmx_prometheus_javaagent.jar /jmx-jar/;
        cp example_configs/kafka-2_0_0.yml /jmx-jar/
    volumes:
      - type: volume
        source: jmx-jar
        target: /jmx-jar
  kafka:
    image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
    entrypoint:
      - /bin/bash
      - -c
      - |
        until test -f "/jmx-jar/jmx_prometheus_javaagent.jar"; do
          sleep 3;
        done;
        until test -f "/jmx-jar/kafka-2_0_0.yml"; do
          sleep 3;
        done;
        ./bin/kafka-server-start.sh /etc/kafka/server.properties
    environment:
      - EXTRA_ARGS=-javaagent:/jmx-jar/jmx_prometheus_javaagent.jar=8080:/jmx-jar/kafka-2_0_0.yml
    volumes:
      - type: volume
        source: jmx-jar
        target: /jmx-jar
    network_mode: host
    depends_on:
      - zookeeper
      - jmx-jar-init
  zookeeper:
    image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
    network_mode: host
    entrypoint:
      - ./bin/zookeeper-server-start.sh
      - /etc/kafka/zookeeper.properties

volumes:
  jmx-jar:

And then metrics were exposed at localhost:8080

@sidps
Copy link
Author

sidps commented Jun 25, 2020

This would imply a mutation on the tag for the existing jmx exporter image, because a new layer has been introduced.

Would it make sense to bump the version? We're currently pointing at 0.12 of the jmx exporter, while 0.13 has been released.

\
apt-get purge -y --auto-remove $buildDeps; \
rm -rf /var/lib/apt/lists/*; \
rm -rf /var/log/dpkg.log /var/log/alternatives.log /var/log/apt
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly a diff, just copy-pasta from above with the appropriate selection in find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant