Confluent Replicator End to End Latency Metrics Required - apache-kafka

Problem Statement: I am trying to figure out end to end latency for replicator from On-prem to AWS data replication. We found in consumer group for replicator we have the option to display the End-to-End latency but it’s not showing any data in the control center as shown in below screenshots. I tried few things as explained below but it’s not working.
What we need to know is:
Which Metrics to be configured for this?
How can we configure these metrics?
Am I exploring the right thing as mentioned below?
Is anyone have any experience or faced similar issues
We tested the consumer group shows the overall messages running behind in the destination cluster.
It’s not showing any data in following screen. I tried figuring out why?
In Replicator connector I added following property to enable interceptor:
What confluent says:
“To monitor production and consumption in Control Center, installed the Confluent Monitoring Interceptors with your Apache Kafka® applications and configure your applications to use the interceptors on the Kafka messages produced and consumed, that are then sent to Control Center.”
We installed this in Replicator as mentioned below:
{
"name":"replicator",
"config":{
....
"src.consumer.interceptor.classes": "io.confluent.monitoring.clients.interceptor.MonitoringConsumerInterceptor",
....
}
}
}
Then I Checked the broker for Confluent Metrics Reporter which is already configured.
Thanks :)

Following are the configuration which worked for me.
FYI..... Control center/Replicator(connect worker) is running on my source cluster.
consumer.properties
zookeeper.connect=src-node1:2181,src-node2:2181,src-node3:2181
bootstrap.servers=src-node1:9092,src-node2,src-node3:9092
interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringConsumerInterceptor
producer.properties
zookeeper.connect=dst-node1:2181,dst-node2:2181,dst-node3:2181
bootstrap.servers=dst-node1:9092,dst-node2:9092,dst-node3:9092
interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor
replicator.properties
#Replication configuration
name=replicator-onprem-to-aws
topic.rename.format=${topic}.replica
replication.factor=1
config.storage.replication.factor=1
offset.storage.replication.factor=1
status.storage.replication.factor=1
confluent.topic.replication.factor=1
If you look into above configuration its the bare basic configuration to run the replicator. I am not using anything fancy here.
then you can run the following command:
[root#src-node1 ~]$ /app/confluent-5.3.1/bin/replicator --cluster.id 1 --consumer.config config/consumer.properties --producer.config config/producer.properties --replication.config config/replicator.properties --whitelist 'test-topic' > replicator.log 2>&1 &

Related

How to pass Apache Kafka Mirrormaker2 config for the producer

I am currently testing Mirrormaker to replicate data between two clusters. Unfortunately it seems the producer config is not utilized by the individual producers then as documented in https://github.com/apache/kafka/blob/trunk/connect/mirror/README.md.
My configuration file simplified:
clusters=INPUT,BACKUP
INPUT.consumer.compression.type=lz4
BACKUP.producer.compression.type=lz4
INPUT->BACKUP.enabled = true
INPUT->BACKUP.topics=mytopic.*
...
Then the log output when running mirrormaker2 (connect-mirror-maker.sh mirrormaker.properties) does not show this option:
INFO ProducerConfig values:
...
compression.type = none
...
The Kafka version in use is 2.7.1.
How can I pass the settings correctly, so the producer is correctly compressing? I also need to pass a few other settings, but once this works it should do for the other settings too.
Two potential solutions:
Enable connector.client.config.override.policy in mm2 workers' property file. You need to follow https://docs.confluent.io/platform/current/connect/references/allconfigs.html#override-the-worker-configuration closely.
Launch a Kafka Connect cluster and create MirrorSourceConnector and MirrorCheckpointConnector one by one with producer configs overridden. You will still need to refer to the official Confluent documentation above. I picked this approach and it works.

kafka MirrorMaker 2.0 does not replicate data

I am trying to replicate Kafka cluster with MirrorMaker 2.0.
I am using following mm2.properties:
# mm2.properties
clusters=source, dest
source.bootstrap.servers=kafka-1:9092,kafka-2:19092,kafka-3:29092
dest.bootstrap.servers=kafka-4:39092,kafka-5:49092,kafka-6:59092
source->dest.enabled=true
I can see that when MirrorMaker starts, it creates its own topics. For example on source cluster it creates: mm2-configs.dest.internal with following content:
{
"properties":{
"connector.class":"org.apache.kafka.connect.mirror.MirrorSourceConnector",
"source.cluster.producer.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092",
"source.cluster.alias":"dest",
"source.cluster.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092",
"target.cluster.producer.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092",
"enabled":"false",
"target.cluster.admin.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092",
"target.cluster.alias":"source",
"target.cluster.consumer.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092",
"name":"MirrorSourceConnector",
"target.cluster.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092",
"source.cluster.admin.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092",
"source.cluster.consumer.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092"
}
}
and at destination cluster mm2-configs.source.internal topic with following content:
{
"properties":{
"connector.class":"org.apache.kafka.connect.mirror.MirrorSourceConnector",
"source.cluster.producer.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092",
"source.cluster.alias":"source",
"source.cluster.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092",
"target.cluster.producer.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092",
"enabled":"true",
"target.cluster.admin.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092",
"target.cluster.alias":"dest",
"target.cluster.consumer.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092",
"name":"MirrorSourceConnector",
"target.cluster.bootstrap.servers":"kafka-4:39092,kafka-5:49092,kafka-6:59092",
"source.cluster.admin.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092",
"source.cluster.consumer.bootstrap.servers":"kafka-1:9092,kafka-2:19092,kafka-3:29092"
}
}
But when I am trying to send messages to source cluster (kafka-1,kafka-2,kafka-3) - nothing copied to the second cluster.
What do I miss?
Appreciate any help
Thx,
mm2 works well in standalone ( single node ) mode, but when it comes to the cluster there is a bug.
The details have been reported here:
https://cwiki.apache.org/confluence/display/KAFKA/KIP-710%3A+Full+support+for+distributed+mode+in+dedicated+MirrorMaker+2.0+clusters
Your config files look ok. However, those bootstrap server ports look off. 19092, 29092, etc. Those are typically 9092 only. Can you try changing those back to 9092?
I think, I found (with help of my friend) what was the problem. In case when topic does NOT exist before starting MirrorMaker, replication won't happen. Topic should exist in source Kafka cluster.
I used Java producer with topic auto create enabled. Seems, automatic topic creation, doesn't trigger MirrorMaker to start replication.
I don't really know if it's as designed behavior when defining source->dest.enabled=true or maybe related to solved few days ago bug: https://github.com/apache/kafka/pull/7745.

How Does Prometheus Scrape a Kafka Topic?

I’m a network guy trying to build my first Kafka --> Prometheus --> Grafana pipeline. My Kafka broker has a topic which is being populated by an external producer. That’s great. But I can’t figure out how to configure my Prometheus server to scrape data from that topic as a Consumer.
I should also say that my Kafka node is running on my host Ubuntu machine (not in a Docker container). I also am running an instance of JMX Exporter when I run Kafka. Here’s how I start up Kafka on the Ubuntu command line:
KAFKA_OPTS="$KAFKA_OPTS -javaagent:/home/me/kafka_2.11-2.1.1/jmx_prometheus_javaagent-0.6.jar=7071:/home/Me/kafka_2.11-2.1.1/kafka-0-8-2.yml" \
./bin/kafka-server-start.sh config/server.properties &
Okay. My Prometheus (also a host process, not the Docker container version) can successfully pull a lot of metrics off of my Kafka. So I just need to figure out how to get Prometheus to read the messages within my topic. And I wonder is those messages are already visible? My topic is called “vflow.sflow,” and when I look at “scrapeable” metrics that is available on Kafka (TCP 7071), I do see these metrics:
From http://localhost:7071/metrics:
kafka_cluster_partition_replicascount{partition="0",topic="vflow.sflow",} 1.0
kafka_cluster_partition_insyncreplicascount{partition="0",topic="vflow.sflow",} 1.0
kafka_log_logendoffset{partition="0",topic="vflow.sflow",} 1.5357405E7
kafka_cluster_partition_laststableoffsetlag{partition="0",topic="vflow.sflow",} 0.0
kafka_log_numlogsegments{partition="0",topic="vflow.sflow",} 11.0
kafka_cluster_partition_underminisr{partition="0",topic="vflow.sflow",} 0.0
kafka_cluster_partition_underreplicated{partition="0",topic="vflow.sflow",} 0.0
kafka_log_size{partition="0",topic="vflow.sflow",} 1.147821017E10
kafka_log_logstartoffset{partition="0",topic="vflow.sflow",} 0.0
“Partition 0,” “Log Size,” “Log End Offset”… all those things look promising… I guess?
But please bear in mind that I’m completely new to the Kafka/JMX/Prometheus ecosystem. Question: do the above metrics describe my “vflow.sflow” topic? Can I use them to configure Prometheus to actually read the messages within the topic?
If so, can someone recommend a good tutorial for this? I’ve been playing around with my Prometheus YAML config files, but all I manage to do is crash the Prometheus process when I do so. Yes, I have been reading the large amount of online documentation and forum posts out there. Its a lot of information to digest, and its very, very easy to invest hours in documentation which proves to be a dead end.
Any advice for a newbie like me? General advice like “you’re on the right track, next look at X” or “you obviously don’t understand Y, spend more time looking at Z” will be def appreciated. Thanks!
When you add that argument from the Kafka container, it scrapes the MBeans of the JMX metrics, not any actual topic data, since Prometheus isn't a Kafka consumer
From that JMX information, you'd see metrics such as message rate and replica counts
If you'd like to read topic data, the Kafka Connect framework could be used, and there's a plugin for Influx, Mongo, and Elasticsearch, which are all good Grafana sources. I'm not sure if there's a direct Kafka to Prometheus importer, but I think it would require using the PushGateway

Use Confluent CLI in order to run several kafka brokers

I wasn't able to find an answer for this, and I'm facing some difficulties while trying to implement it.
Does confluent command only is able to run multiple brokers + Zookeeper?
Is it possible to build a kafka cluster consist of 3 nodes, using Confluent CLI?
Thanks.
No, it does not support multi-node clusters.
It only runs a single localhost kafka-server-start and zookeeper-server-start commands.
Additionally, as mentioned on the documentation page
meant for development purposes only and is not suitable for a production environment. The data that are produced are transient and are intended to be temporary.
By "production environment" here, it is implied as multiple servers.

Consume from Kafka 0.10.x topic using Storm 0.10.x (KafkaSpout)

I am not sure if this a right question to ask in this forum. We were consuming from a Kafka topic by Storm using the Storm KafkaSpout connector. It was working fine till now. Now we are supposed to connect to a new Kafka cluster having upgraded version 0.10.x from the same Storm env which is running on version 0.10.x.
From storm documentation (http://storm.apache.org/releases/1.1.0/storm-kafka-client.html) I can see that storm 1.1.0 is compatible with Kafka 0.10.x onwards supporting the new Kafka consumer API. But in that case I won't be able to run the topology in my end (please correct me if I am wrong).
Is there any work around for this?
I have seen that even if the New Kafka Consumer API has removed ZooKeeper dependency but we can still consume message from it using the old Kafka-console-consumer.sh by passing the --zookeeper flag instead of new –bootstrap-server flag (recommended). I run this command from using Kafka 0.9 and able to consume from a topic hosted on Kafka 0.10.x
When we are trying to connect getting the below exception:
java.lang.RuntimeException: java.lang.RuntimeException: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /brokers/topics/mytopic/partitions
at storm.kafka.DynamicBrokersReader.getBrokerInfo(DynamicBrokersReader.java:81) ~[stormjar.jar:?]
at storm.kafka.trident.ZkBrokerReader.<init>(ZkBrokerReader.java:42) ~[stormjar.jar:?]
But we are able to connect to the remote ZK server and validated that the path exists:
./zkCli.sh -server remoteZKServer:2181
[zk: remoteZKServer:2181(CONNECTED) 5] ls /brokers/topics/mytopic/partitions
[3, 2, 1, 0]
As we can see above that it's giving us expected output as the topic has 4 partitions in it.
At this point have the below questions:
1) Is it at all possible to connect to Kafka 0.10.x using Storm version 0.10.x ? Has one tried this ?
2) Even if we are able to consume, do we need to make any code change in order to retrieve the message offset in case of topology shutdown/restart. I am asking this as we will passing the Zk cluster details instead of the brokers info as supported in old KafkaSpout version.
Running out of options here, any pointers would be highly appreciated
UPDATE:
We are able to connect and consume from the remote Kafka topic while running it locally using eclipse. To make sure storm does not uses the in-memory zk we have used the overloaded constructor LocalCluster("zkServer",port), it's working fine and we can see the data coming. This lead us to conclude that version compatibility might not be the issue here.
However still no luck when deployed the topology in cluster.
We have verified the connectivity from storm box to zkservers
The znode seems fine also ..
At this point really need some pointers here, what could possibly be wrong with this and how do we debug that? Never worked with Kafka 0.10x before so not sure what exactly are we missing.
Really appreciate some help and suggestions
Storm 0.10x is compatible with Kafka 0.10x . We can still uses the old KafkaSpout that depends on zookeeper based offset storage mechanism.
The connection loss exception was coming as we were trying to reach a remote Kafka cluster that does not allow/accept connection from our end. We need to open specific firewall port so that the connection can be established. It seems that while running topology is cluster mode all the supervisor nodes should be able to talk to the zookeeper, so the firewall should be open for each one of them.