niaomingjian
niaomingjian

Reputation: 3742

kafka AdminClient get kafka version

Is there a way to get the version of kafka cluster programmatically? Such as, using AdminClient API.

I want to identify the version of kafka cluster in a consumer/producer app.

Upvotes: 4

Views: 3340

Answers (2)

Mickael Maison
Mickael Maison

Reputation: 26885

At the moment there is no way to retrieve the Kafka version brokers are running.

There is a KIP in progress to add that feature to the AdminClient: KIP-483: Add Broker Version API in Admin Client so that may be availabble in a future version.

In the meantime, there are a few workarounds you can try:

  • Use describeConfigs() to find the inter.broker.protocol.version config of the brokers. If that returns 2.2-IV1, it means the broker is running at least 2.2.

  • Check the ApiVersions response. Upon starting clients send an ApiVersions request and the response is written in the logs (at the INFO level). Or manually send an ApiVersions, it's pretty easy to craft such a request as it's an empty body. Then you can identify the broker version using https://cwiki.apache.org/confluence/display/KAFKA/Kafka+APIs

Upvotes: 5

sev7e0
sev7e0

Reputation: 106

You can use AppInfoParser.getVersion(); in your consumer/producer code.

Upvotes: 1

Related Questions