[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>
jsoriano
left a comment
There was a problem hiding this comment.
This is looking good, I am requesting only some small changes in Dockerfile and configuration.
| 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.
curl was already installed, you can use it, and you can also use retry as is being used to download kafka.
| 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 |
| metricsets: ["broker", "consumer", "consumergroup", "partition", "producer"] | ||
| period: 10s | ||
| hosts: ["localhost:9092"] | ||
| enabled: true |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.producermetricset 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/partitionVerify 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_1In this example the mapping is:
0.0.0.0:32769->87790.0.0.0:32770->87750.0.0.0:32771->8774So 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.