-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Metricbeat] Add Kafka JMX metricsets #14330
Conversation
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
7194cc1
to
c2da3a3
Compare
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, I am requesting only some small changes in Dockerfile and configuration.
@@ -8,20 +8,30 @@ ENV KAFKA_LOGS_DIR="/kafka-logs" | |||
ENV _JAVA_OPTIONS "-Djava.net.preferIPv4Stack=true" | |||
ENV TERM=linux | |||
|
|||
RUN apt-get update && apt-get install -y curl openjdk-8-jre-headless netcat dnsutils | |||
RUN apt-get update && apt-get install -y curl openjdk-8-jre-headless netcat dnsutils wget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curl
was already installed, you can use it, and you can also use retry
as is being used to download kafka.
|
||
RUN mkdir -p ${KAFKA_LOGS_DIR} && mkdir -p ${KAFKA_HOME} && \ | ||
curl -J -L -s -f -o - https://github.com/kadwanev/retry/releases/download/1.0.1/retry-1.0.1.tar.gz | tar xfz - -C /usr/local/bin && \ | ||
retry --min 1 --max 180 -- curl -J -L -s -f --show-error -o $INSTALL_DIR/kafka.tgz \ | ||
"https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_2.11-${KAFKA_VERSION}.tgz" && \ | ||
tar xzf ${INSTALL_DIR}/kafka.tgz -C ${KAFKA_HOME} --strip-components 1 | ||
|
||
RUN wget -O /opt/jolokia-jvm-1.5.0-agent.jar http://search.maven.org/remotecontent\?filepath\=org/jolokia/jolokia-jvm/1.5.0/jolokia-jvm-1.5.0-agent.jar | ||
# RUN mv jolokia-jvm-1.5.0-agent.jar /opt/jolokia-jvm-1.5.0-agent.jar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented out code.
@@ -1,5 +1,5 @@ | |||
- module: kafka | |||
metricsets: ["consumergroup", "partition"] | |||
metricsets: ["broker", "consumer", "consumergroup", "partition", "producer"] | |||
period: 10s | |||
hosts: ["localhost:9092"] | |||
enabled: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the hosts in the config should be different for the different metricsets, we could put it in different blocks in the reference configuration, also adding a note about the expected host, something like what we do in the kubernetes module, something like this:
# Kafka metrics collected using the Kafka protocol
- module: kafka
enabled: true
metricsets:
- consumergroup
- partition
period: 10s
hosts: ["localhost:9092"]
# Metrics collected from a Kafka broker using Jolokia
#- module: kafka
# enabled: true
# metricsets: ['broker']
# period: 10s
# hosts: ['localhost:8779']
# Metrics collected from a Java Kafka consumer using Jolokia
#- module: kafka
# enabled: true
# metricsets: ['consumer']
# period: 10s
# hosts: ['localhost:8775']
# Metrics collected from a Java Kafka producer using Jolokia
#- module: kafka
# enabled: true
# metricsets: ['producer']
# period: 10s
# hosts: ['localhost:8774']
# - consumergroup | ||
# - producer | ||
period: 10s | ||
hosts: ["localhost:9092"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need a similar separation as the one suggested above for the reference config. Or we could have just one config.yml
with the suggestions mentioned before and remove the config.reference.yml
.
KAFKA_OPTS="-Djava.security.auth.login.config=/kafka/bin/jaas-kafka-client-consumer.conf -javaagent:/opt/jolokia-jvm-1.5.0-agent.jar=port=8774,host=0.0.0.0" \ | ||
${KAFKA_HOME}/bin/kafka-console-consumer.sh --topic=test --bootstrap-server=localhost:9091 --consumer.config ${KAFKA_HOME}/bin/sasl-producer.properties > /dev/null & | ||
|
||
wait_for_port 8774 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to myself 🙂 consider separating it in several entrypoints for #14087.
Don't do it here because it will only complicate this PR and it is not needed by now.
|
||
[float] | ||
=== Compatibility | ||
The module has been tested with Kafka 2.1.1. Other versions are expected to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may add here also a link to the Jolokia module for the compatibility notes there.
description: Broker metrics from Kafka Broker JMX | ||
release: beta | ||
fields: | ||
- name: mbean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mbeans should be always in the same field at the root level (something like jmx.mbean
).
This is probably something to change in the Jolokia module, so we can keep this here by now.
@@ -0,0 +1,20 @@ | |||
This metricset periodically fetches JMX metrics from Kafka Producers JMX. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to explicitly mention that this only works for consumers implemented in Java, and same thing in the producer metricset.
Btw:
This metricset periodically fetches JMX metrics from Kafka Producers JMX. | |
This metricset periodically fetches JMX metrics from Kafka Consumers JMX. |
|
||
[float] | ||
=== Usage | ||
The Producer metricset requires <<metricbeat-module-jolokia,Jolokia>>to fetch JMX metrics. Refer to the link for instructions about how to use Jolokia. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also mention something about the metricsets requiring Jolokia in the module documentation (metricbeat/module/kafka/_meta/docs.asciidoc
).
baba2b9
to
651fe2f
Compare
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Merging this one since Travis succeeded and Jenkins failure is irrelevant. Tests will be added in a follow up PR. |
(cherry picked from commit 87c49ac)
Regression should be fixed now with the fixes at #15957. |
Tested manually, good work! |
Implements
kafka.broker
,kafka.consumer
,kafka.producer
metricset of #13366.Depends on:
Manual Testing
Broker metricset
In order to prepare the proper environment to test these metricsets, the quickest way is to reuse the Docker env of the module. This can be achieved by first of all running the integration tests of the module which will take care of bringing up the container with the proper configuration.
To run the tests:
go test -v -tags=integration github.com/elastic/beats/metricbeat/module/kafka/partition
Verify that tests are successful and you can go on to manual testing. After the tests have finished the container is still alive so we can use it for the manual testing too.
Check what are the exported ports from Docker with a
docker ps
:5da9631cfa25 docker.elastic.co/observability-ci/beats-integration-kafka:2.1.1-1 "/run.sh" 23 minutes ago Up 23 minutes (healthy) 2181/tcp, 0.0.0.0:32771->8774/tcp, 0.0.0.0:32770->8775/tcp, 0.0.0.0:32769->8779/tcp, 0.0.0.0:32768->9092/tcp metricbeat_kafka_1
In this example the mapping is:
0.0.0.0:32769->8779
0.0.0.0:32770->8775
0.0.0.0:32771->8774
So we configure the metricsets' hosts accordingly.
Enable the Kafka module and use the following configuration in
modules.d/kafka.yml
:Run Metricbeat and verify that metrics are being collected from all of the 3 metricsets we configured.
When done remove the testing container.