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

update kafka version used in testing to 3.6.0 #42286

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f91ba00
update kafka version used in testing
khushijain21 Nov 29, 2024
3d92737
Merge remote-tracking branch 'upstream/main' into kafka_version
khushijain21 Dec 3, 2024
399d96d
some environment changes
khushijain21 Dec 3, 2024
c3870d0
boostrap
khushijain21 Dec 3, 2024
8db25bb
3.6.0 versio change
khushijain21 Dec 4, 2024
69bb623
Update metricbeat/module/kafka/_meta/healthcheck.sh
khushijain21 Dec 18, 2024
415dde3
uncomment compose waiting
stefans-elastic Jan 10, 2025
dbf8a4e
Merge branch 'main' into kafka_version
stefans-elastic Jan 10, 2025
32df9bd
kafka 3.6.0 fix
stefans-elastic Jan 14, 2025
7c8a919
Merge branch 'kafka_version' of github.com:stefans-elastic/beats into…
stefans-elastic Jan 14, 2025
a31b451
Merge branch 'main' of github.com:stefans-elastic/beats into kafka_ve…
stefans-elastic Jan 20, 2025
943e49e
fix mistake in path to adminclient.properties
stefans-elastic Jan 20, 2025
d21f8f4
fix kafka image link in docker-compose
stefans-elastic Jan 20, 2025
1acda5d
fix libbeats kafka docker testing image
stefans-elastic Jan 20, 2025
50c9657
Merge branch 'main' of github.com:stefans-elastic/beats into kafka_ve…
stefans-elastic Jan 20, 2025
470dbc1
bump kafka to 2.13
stefans-elastic Jan 20, 2025
fb00779
update kafka version in partition.go
stefans-elastic Jan 21, 2025
0bfa5bb
Merge branch 'main' of github.com:stefans-elastic/beats into kafka_ve…
stefans-elastic Jan 21, 2025
9b0202f
Merge branch 'main' into kafka_version
stefans-elastic Jan 28, 2025
9d55765
Merge branch 'main' into kafka_version
stefans-elastic Jan 29, 2025
4fdb5b9
update kafka version in docs
stefans-elastic Jan 29, 2025
90db16e
Merge branch 'main' into kafka_version
stefans-elastic Feb 4, 2025
92994db
Merge branch 'main' into kafka_version
stefans-elastic Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion libbeat/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '2.3'
services:
# This is a proxy used to block "docker-compose up" until all services are healthy.
# See: https://github.com/docker/compose/issues/4369
Expand Down
2 changes: 0 additions & 2 deletions metricbeat/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '2.3'

services:
beat:
build: ${PWD}/.
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/modules/kafka.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ kafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --add --allo
[float]
=== Compatibility

This module is tested with Kafka 0.10.2.1, 1.1.0, 2.1.1, and 2.2.2.
This module is tested with Kafka 0.10.2.1, 1.1.0, 2.1.1, 2.2.2 and 3.6.0.

The Broker, Producer, Consumer metricsets require <<metricbeat-module-jolokia,Jolokia>> to fetch JMX metrics. Refer to the link for Jolokia's compatibility notes.

Expand Down
8 changes: 4 additions & 4 deletions metricbeat/module/kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ To bring this container up simply run the tests for Kafka module:
After the tests have been completed, the Kafka container should be still running. Verify with:

```console
707b50334835 docker.elastic.co/integrations-ci/beats-kafka:2.2.2-2 "/run.sh" 2 minutes ago Up 2 minutes (healthy) 2181/tcp, 0.0.0.0:32785->8774/tcp, 0.0.0.0:32784->8775/tcp, 0.0.0.0:32783->8779/tcp, 0.0.0.0:32782->9092/tcp kafka_a035cf4c6889705a_kafka_1
707b50334835 docker.elastic.co/integrations-ci/beats-kafka:3.6.0-2 "/run.sh" 2 minutes ago Up 2 minutes (healthy) 2181/tcp, 0.0.0.0:32785->8774/tcp, 0.0.0.0:32784->8775/tcp, 0.0.0.0:32783->8779/tcp, 0.0.0.0:32782->9092/tcp kafka_a035cf4c6889705a_kafka_1
```

In order to identify to which port the Broker is listening on one should check in the logs of the container and find
In order to identify to which port the Broker is listening on one should check in the logs of the container and find
the advertised address:

```console
Expand All @@ -39,7 +39,7 @@ listeners = INSIDE://localhost:9091,OUTSIDE://0.0.0.0:9092
```

So here in this example the host we should in the module's config is `localhost:32778`.
Note that this is different between MAC and Linux machines. The above is the case for the MAC machine, and here is how
Note that this is different between MAC and Linux machines. The above is the case for the MAC machine, and here is how
the respective address for a LINUX machine should look like:

```console
Expand All @@ -60,7 +60,7 @@ This was needed before moving the metricbeat docker used in CI to host network,

#### Configuring Kafka module
In order to configure the Module we will use the advertised addressed to connect to the broker and the credentials
that are also used for the tests
that are also used for the tests
(see [test config](https://github.com/elastic/beats/blob/6c279ebf2789655725889f37820c959a8f2ea969/metricbeat/module/kafka/consumergroup/consumergroup_integration_test.go#L39)).
Here is how the config should look like (in a MAC):

Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/kafka/_meta/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ RUN apt-get update && apt-get install -y curl openjdk-8-jre-headless netcat-open
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" && \
"https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_2.13-${KAFKA_VERSION}.tgz" && \
tar xzf ${INSTALL_DIR}/kafka.tgz -C ${KAFKA_HOME} --strip-components 1

RUN retry --min 1 --max 180 -- curl -J -L -s -f --show-error -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

ADD adminclient.properties /kafka/bin/adminclient.properties
ADD kafka_server_jaas.conf /etc/kafka/server_jaas.conf
ADD jaas-kafka-client-producer.conf /kafka/bin/jaas-kafka-client-producer.conf
ADD sasl-producer.properties /kafka/bin/sasl-producer.properties
Expand Down
3 changes: 3 additions & 0 deletions metricbeat/module/kafka/_meta/adminclient.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username=admin password=admin-secret;
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --add --allo
[float]
=== Compatibility

This module is tested with Kafka 0.10.2.1, 1.1.0, 2.1.1, and 2.2.2.
This module is tested with Kafka 0.10.2.1, 1.1.0, 2.1.1, 2.2.2 and 3.6.0.

The Broker, Producer, Consumer metricsets require <<metricbeat-module-jolokia,Jolokia>> to fetch JMX metrics. Refer to the link for Jolokia's compatibility notes.

Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/kafka/_meta/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

TOPIC="foo-`date '+%s-%N'`"

${KAFKA_HOME}/bin/kafka-topics.sh --zookeeper=127.0.0.1:2181 --create --partitions 1 --topic "${TOPIC}" --replication-factor 1
${KAFKA_HOME}/bin/kafka-topics.sh --bootstrap-server localhost:9091 --command-config ${KAFKA_HOME}/bin/adminclient.properties --create --partitions 1 --topic "${TOPIC}" --replication-factor 1
rc=$?
if [[ $rc != 0 ]]; then
exit $rc
fi

${KAFKA_HOME}/bin/kafka-topics.sh --zookeeper=127.0.0.1:2181 --delete --topic "${TOPIC}"
${KAFKA_HOME}/bin/kafka-topics.sh --bootstrap-server localhost:9091 --command-config ${KAFKA_HOME}/bin/adminclient.properties --delete --topic "${TOPIC}"
exit 0
16 changes: 9 additions & 7 deletions metricbeat/module/kafka/_meta/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ wait_for_port() {
nc -z localhost $port
}

${KAFKA_HOME}/bin/kafka-topics.sh --zookeeper=127.0.0.1:2181 --create --partitions 1 --topic test --replication-factor 1
${KAFKA_HOME}/bin/kafka-topics.sh --bootstrap-server localhost:9091 --create --partitions 1 --topic test --replication-factor 1 --command-config ${KAFKA_HOME}/bin/adminclient.properties

echo "Starting ZooKeeper"
${KAFKA_HOME}/bin/zookeeper-server-start.sh ${KAFKA_HOME}/config/zookeeper.properties &
Expand All @@ -44,7 +44,7 @@ echo "Starting Kafka broker"
mkdir -p ${KAFKA_LOGS_DIR}
export KAFKA_OPTS="-Djava.security.auth.login.config=/etc/kafka/server_jaas.conf -javaagent:/opt/jolokia-jvm-1.5.0-agent.jar=port=8779,host=0.0.0.0"
${KAFKA_HOME}/bin/kafka-server-start.sh ${KAFKA_HOME}/config/server.properties \
--override authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer \
--override authorizer.class.name=kafka.security.authorizer.AclAuthorizer \
--override super.users=User:admin \
--override sasl.enabled.mechanisms=PLAIN \
--override sasl.mechanism.inter.broker.protocol=PLAIN \
Expand All @@ -53,6 +53,7 @@ ${KAFKA_HOME}/bin/kafka-server-start.sh ${KAFKA_HOME}/config/server.properties \
--override advertised.listeners=INSIDE://localhost:9091,OUTSIDE://$KAFKA_ADVERTISED_HOST \
--override listener.security.protocol.map=INSIDE:SASL_PLAINTEXT,OUTSIDE:SASL_PLAINTEXT \
--override inter.broker.listener.name=INSIDE \
--override zookeeper.set.acl=false \
--override logs.dir=${KAFKA_LOGS_DIR} &

wait_for_port 9092
Expand All @@ -62,22 +63,23 @@ wait_for_port 8779
echo "Kafka load status code $?"

# ACLS used to prepare tests
${KAFKA_HOME}/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:producer --operation All --cluster --topic '*' --group '*'
${KAFKA_HOME}/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:consumer --operation All --cluster --topic '*' --group '*'
${KAFKA_HOME}/bin/kafka-acls.sh --bootstrap-server localhost:9091 --command-config ${KAFKA_HOME}/bin/adminclient.properties --add --allow-principal User:producer --operation All --cluster --topic '*' --group '*'
${KAFKA_HOME}/bin/kafka-acls.sh --bootstrap-server localhost:9091 --command-config ${KAFKA_HOME}/bin/adminclient.properties --add --allow-principal User:consumer --operation All --cluster --topic '*' --group '*'

# Minimal ACLs required by metricbeat. If this needs to be changed, please update docs too
${KAFKA_HOME}/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:stats --operation Describe --group '*'
${KAFKA_HOME}/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:stats --operation Read --topic '*'
${KAFKA_HOME}/bin/kafka-acls.sh --bootstrap-server localhost:9091 --command-config ${KAFKA_HOME}/bin/adminclient.properties --add --allow-principal User:stats --operation Describe --group '*'
${KAFKA_HOME}/bin/kafka-acls.sh --bootstrap-server localhost:9091 --command-config ${KAFKA_HOME}/bin/adminclient.properties --add --allow-principal User:stats --operation Read --topic '*'

touch /tmp/.acls_loaded


echo "Kafka producer start"
# Start a forever producer
{ while sleep 1; do echo message; done } | KAFKA_OPTS="-Djava.security.auth.login.config=/kafka/bin/jaas-kafka-client-producer.conf -javaagent:/opt/jolokia-jvm-1.5.0-agent.jar=port=8775,host=0.0.0.0" \
${KAFKA_HOME}/bin/kafka-console-producer.sh --topic test --broker-list localhost:9091 --producer.config ${KAFKA_HOME}/bin/sasl-producer.properties > /dev/null &

wait_for_port 8775

echo "Kafka consumer start"
# Start a forever consumer
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 &
Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/kafka/_meta/supported-versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variants:
- KAFKA_VERSION: 3.6.0
- KAFKA_VERSION: 2.2.2
- KAFKA_VERSION: 2.1.1
- KAFKA_VERSION: 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/broker/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This metricset periodically fetches JMX metrics from Kafka Broker JMX.

[float]
=== Compatibility
The module has been tested with Kafka 2.1.1 and 2.2.2. Other versions are expected to work.
The module has been tested with Kafka 2.1.1, 2.2.2 and 3.6.0. Other versions are expected to work.

[float]
=== Usage
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/consumer/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This metricset periodically fetches JMX metrics from Kafka Consumers implemented

[float]
=== Compatibility
The module has been tested with Kafka 2.1.1 and 2.2.2. Other versions are expected to work.
The module has been tested with Kafka 2.1.1, 2.2.2 and 3.6.0. Other versions are expected to work.

[float]
=== Usage
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/consumergroup/consumergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var debugf = logp.MakeDebug("kafka")
// New creates a new instance of the MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
opts := kafka.MetricSetOptions{
Version: "2.2.0",
Version: "3.6.0",
}

ms, err := kafka.NewMetricSet(base, opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func startConsumer(t *testing.T, host string, groupID string) (io.Closer, error)
// Create a new consumer group
consumerGroup, err := sarama.NewConsumerGroup(brokers, groupID, config)
if err != nil {
t.Fatalf("Error creating consumer group: %v", err)
t.Fatalf("Error creating consumer group: %v, brokers: %s", err, brokers)
return nil, err
}

Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/kafka/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
services:
kafka:
image: docker.elastic.co/integrations-ci/beats-kafka:${KAFKA_VERSION:-2.2.2}-2
image: docker.elastic.co/integrations-ci/beats-kafka:${KAFKA_VERSION:-3.6.0}-2
build:
context: ./_meta
args:
KAFKA_VERSION: ${KAFKA_VERSION:-2.2.2}
KAFKA_VERSION: ${KAFKA_VERSION:-3.6.0}
ports:
- 9092
- 8779
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/partition/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var debugf = logp.MakeDebug("kafka")
// New creates a new instance of the partition MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
opts := kafka.MetricSetOptions{
Version: "2.2.0",
Version: "3.6.0",
}

ms, err := kafka.NewMetricSet(base, opts)
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/producer/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This metricset periodically fetches JMX metrics from Kafka Producers implemented

[float]
=== Compatibility
The module has been tested with Kafka 2.1.1 and 2.2.2. Other versions are expected to work.
The module has been tested with Kafka 2.1.1, 2.2.2 and 3.6.0. Other versions are expected to work.

[float]
=== Usage
Expand Down
4 changes: 2 additions & 2 deletions testing/environments/docker/kafka/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV KAFKA_HOME=/kafka
ENV KAFKA_ADVERTISED_HOST=kafka

ENV KAFKA_LOGS_DIR="/kafka-logs"
ENV KAFKA_VERSION=2.2.2
ENV KAFKA_VERSION=3.6.0
ENV _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"
ENV TERM=linux

Expand All @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y curl openjdk-11-jre-headless netcat-ope
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" && \
"https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_2.13-${KAFKA_VERSION}.tgz" && \
tar xzf ${INSTALL_DIR}/kafka.tgz -C ${KAFKA_HOME} --strip-components 1

ADD run.sh /run.sh
Expand Down
4 changes: 2 additions & 2 deletions testing/environments/docker/kafka/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

TOPIC="foo-`date '+%s-%N'`"

${KAFKA_HOME}/bin/kafka-topics.sh --zookeeper=127.0.0.1:2181 --create --partitions 1 --topic "${TOPIC}" --replication-factor 1
${KAFKA_HOME}/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --partitions 1 --topic "${TOPIC}" --replication-factor 1
rc=$?
if [[ $rc != 0 ]]; then
exit $rc
fi

${KAFKA_HOME}/bin/kafka-topics.sh --zookeeper=127.0.0.1:2181 --delete --topic "${TOPIC}"
${KAFKA_HOME}/bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic "${TOPIC}"
exit 0
14 changes: 7 additions & 7 deletions testing/environments/docker/kafka/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ echo "Starting ZooKeeper"
${KAFKA_HOME}/bin/zookeeper-server-start.sh ${KAFKA_HOME}/config/zookeeper.properties &
wait_for_port 2181

# create a user beats with password KafkaTest, for use in client SASL authentication
/kafka/bin/kafka-configs.sh \
--zookeeper localhost:2181 \
--alter --add-config 'SCRAM-SHA-512=[password=KafkaTest]' \
--entity-type users \
--entity-name beats

# Start Kafka with three listeners. The INSIDE listener makes Kafka reachable inside of docker
# networks when the container hostname matches KAFKA_ADVERTISED_HOST. The OUTSIDE and SASL_SSL both
# bind to localhost and are reachable from the host machine on the loopback interface.
Expand All @@ -49,5 +42,12 @@ wait_for_port 9092

echo "Kafka load status code $?"

# create a user beats with password KafkaTest, for use in client SASL authentication
/kafka/bin/kafka-configs.sh \
--bootstrap-server localhost:9092 \
--alter --add-config 'SCRAM-SHA-512=[password=KafkaTest]' \
--entity-type users \
--entity-name beats

# Make sure the container keeps running
tail -f /dev/null
Loading