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

Add Jolokia #450

Closed
wants to merge 14 commits into from
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ENV KAFKA_VERSION=$kafka_version \

ENV PATH=${PATH}:${KAFKA_HOME}/bin

COPY download-kafka.sh start-kafka.sh broker-list.sh create-topics.sh versions.sh /tmp/
COPY download-kafka.sh start-kafka.sh broker-list.sh create-topics.sh versions.sh download-jolokia.sh /tmp/

RUN apk add --no-cache bash curl jq docker \
&& mkdir /opt \
Expand All @@ -32,6 +32,7 @@ RUN apk add --no-cache bash curl jq docker \
&& tar xfz /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -C /opt \
&& rm /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz \
&& ln -s /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} /opt/kafka \
&& /tmp/download-jolokia.sh \
&& rm /tmp/* \
&& wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
&& apk add --no-cache --allow-untrusted glibc-${GLIBC_VERSION}.apk \
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ For example, to connect to a kafka running locally (assumes exposing port 1099)

Jconsole can now connect at ```jconsole 192.168.99.100:1099```

## Jolokia

For get JMX Metric via jolokia HTTP, set environment

```
KAFKA_JOLOKIA_PORT: 7777
```


## Docker Swarm Mode

The listener configuration above is necessary when deploying Kafka in a Docker Swarm using an overlay network. By separating OUTSIDE and INSIDE listeners, a host can communicate with clients outside the overlay network while still benefiting from it from within the swarm.
Expand Down
5 changes: 5 additions & 0 deletions download-jolokia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -e

wget "http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.6.0/jolokia-jvm-1.6.0-agent.jar" -O "/tmp/jolokia-jvm-1.6.0-agent.jar"
mv "/tmp/jolokia-jvm-1.6.0-agent.jar" /opt/kafka/libs
chmod a+x /opt/kafka/libs/jolokia-jvm-1.6.0-agent.jar
5 changes: 5 additions & 0 deletions start-kafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ if [[ -z "$KAFKA_ADVERTISED_HOST_NAME$KAFKA_LISTENERS" ]]; then
export KAFKA_ADVERTISED_HOST_NAME="$HOSTNAME_VALUE"
fi

# Jolokia
if [[ -n "$KAFKA_JOLOKIA_PORT" ]]; then
export KAFKA_OPTS="-javaagent:$KAFKA_HOME/libs/jolokia-jvm-1.6.0-agent.jar=port=$KAFKA_JOLOKIA_PORT,host=0.0.0.0 $KAFKA_OPTS"
fi

#Issue newline to config file in case there is not one already
echo "" >> "$KAFKA_HOME/config/server.properties"

Expand Down