BetterCloud / kadmin

Web Based Kafka Consumer and Producer
69 stars 25 forks source link

Kadmin - Kafka Producer/Consumer UI

Purpose

Companies like Confluent provide command line utilities for producing/consumer Kafka topics. However, these tools are extremely difficult to use when other technologies are introduced, e.g. avro, or attempting to debug your application by attempting to parse globs of unformatted json.

Depending on deployment strategies, developers and QA are not able to use these tools in deployed environment for testing/debugging.

This service provides similar functionality with a more user friendly interface wrapped in an easily deployable micro-service.

Overview

Similar to the command line tools Kadmin can spin up consumers and producers on the fly.

Consumers

Consumers keep a queue of the latest n (default 100) messages from a topic. When a consumer spins up, it starts with the auto.offset.reset=latest configuration. After an initialization poll, the consumer will seek to max(po - n / pc, 0) for each partition where po is the offset for that partition and pc is the total number of partitions. This allows the consumer to pull the latest messages from each partition.

Producers

Producers behave the same as command line tools. Not that depending on your kafka/schema registry configurations, you might need to create topics and schemas manually.

Installing and Running

Kadmin uses Kafka 0.9.* and Confluent 3.*. Follow the confluent quickstart guide to get your local environment setup.

Kadmin requires Java 1.8+.

Configuring

See the Configuration section for a full list of configurations, descriptions, and default values.

Running From Executable

  1. You can find a prebuilt executable jar in the /dist directory.
  2. You can run the jar using java -jar shared-kafka-admin-micro-0.1.0.jar --spring.profiles.active=desired,Spring,profiles
  3. Access the application using http://localhost:8080/kadmin/ providing the correct port and path context.

Example

cd <base>
cd dist
cp ../application.properties .
java -jar shared-kafka-admin-micro-*.jar --spring.profiles.active=kadmin,local

Run From Source

  1. run ./gradlew bootRun or use your cli/ide to execute com.bettercloud.kadmin.Application#main
  2. Access the application using http://localhost:8080/kadmin/ or the provide the correct port and path context.

Run From Docker Container

https://cloud.docker.com/u/bettercloud/repository/docker/bettercloud/kadmin

  1. run docker image
docker run -d -name kadmin bettercloud/kadmin
  1. run docker compose file
    docker-compose up

Take the following variables into consideration when running the container:

  1. ZOOKEEPER_HOST: zookeeper host
  2. KAFKA_HOST: kafka host
  3. SECURITY_PROTOCOL: security protocol (SSL or PLAINTEXT)
  4. TRUST_STORE_LOCATION: absolute location of the truststore jks file
  5. TRUST_STORE_PASSWORD: truststore password
  6. KEY_STORE_LOCATION: absolute location of the keystore jks file
  7. KEY_STORE_PASSWORD: keystore password
  8. KEY_PASSWORD: key password

Building and Running From An Executable JAR

  1. run ./gradlew clean build
  2. You can find the executable jar in build/libs e.g. build/libs/shared-kafka-admin-micro-0.1.0.jar
  3. If you used <base>/application.properties then copy that file to the same directory as the executable jar.
  4. You can run the jar using java -jar shared-kafka-admin-micro-0.1.0.jar --spring.profiles.active=desired,Spring,profiles
  5. Access the application using http://localhost:8080/kadmin/ providing the correct port and path context.

Example

cd <base>
rm -rf dist
mkdir dist
./gradlew clean build
cp build/libs/shared-kafka-admin-micro-*.jar dist/
cp application.properties dist/
cd dist
java -jar shared-kafka-admin-micro-*.jar --spring.profiles.active=kadmin,local

Usage

Consuming Messages

Starting The Consumer

  1. Depending on the configuration, specify the kafka/schema registry urls.
  2. Select the topic
  3. Select the deserializer
  4. Click "Start Consumer"

Consumer

Viewing the Consumer

Once the consumer has been started, you have the following options.

Consumer Tab

Viewing the Messages

Producing Messages

Primitive Types

  1. Depending on the configuration, specify the kafka/schema registry urls.
  2. Select the topic from the drop down or enter the topic name in the text box
  3. Specify the count i.e. number of messages to send e.g. 10000 for a load test.
  4. Select the serializer
  5. Optionally specify a message key.
  6. Enter message payload
  7. Click "Send"
  8. Check the results and stats at the bottom of the page for success and production rate.

Basic Producer

Avro

  1. Depending on the configuration, specify the kafka/schema registry urls.
  2. Select the topic from the drop down or enter the topic name in the text box
  3. Specify the count i.e. number of messages to send e.g. 10000 for a load test.
  4. Select the schema key and version from the dropdowns or enter the raw schema
  5. Optionally specify a message key.
  6. Enter message payload
  7. Click "Send"
  8. Check the results and stats at the bottom of the page for success and production rate.

Avro Producer

Manager

Allows management of active connections to brokers. Displays information about topics currently being consumed. Provides actions for each active consumer

Also, allows for clean disposal of producers.

Manager

Configuration

Config locations

Kafka Consumers and Producers

The consumer and producer has reasonable defaults, but these can be overridden using configurations from http://kafka.apache.org/documentation.html#newconsumerconfigs.

Kadmin Configs

Config Description Default Possible Values
server.contextPath The following config sets the spring context path. You will access the application at http:/// e.g. http://localhost:8080/kadmin null Any valid url path element e.g. /kadmin
server.port The port that the tomcat service will listen on. 8080 Any valid port
ff.producer.enabled Toggles read only mode i.e. Kafka producers are disabled. You can use the following Spring profile or the raw config. false true, false
ff.customKafkaUrl.enabled Allows custom urls to be used for Kafka and Service Registry for each producer and consumer. false true, false
kafka.host If ff.customKafkaUrl.enabled is disabled then you need to configure the default endpoints using the following configs. kafka.host is a comma separated list of kafka brokers. localhost:9092 Valid hosts separated by commas.
schema.registry.url Allows custom urls to be used for Kafka and Service Registry for each producer and consumer. http://localhost:8081 Any valid host url

Version History

Note that changes to the major version (i.e. the first number) represent possible breaking changes, and may require modifications in your code to migrate. Changes to the minor version (i.e. the second number) should represent non-breaking changes. The third number represents any very minor bugfix patches.

Development

Pull requests are welcomed for bugfixes or small enhancements. For more complex changes please open up an issue to discuss it first.

All code changes should include unit test and/or integration test coverage as appropriate. Unit tests are any that can be run in isolation, with no external dependencies. Integration tests are those which require kafka, zookeeper, and/or a schema registry instance (at least a Dev instances) up and running.

Unit tests are located under the src/test directory, and can be run with the Grade unitTest task.

Integration tests are located under the src/test-integration directory, and can be run with the Gradle integrationTest task. See the additional README.md file in this directory for more detailed information on the kafka, zookeeper, schema registry, and avro required to run the integration test suite.

Adding New Serializers

// coming soon...

Please contact david.esposito@bettercloud.com if you need this documentation sooner than later.

Adding New Deserializers

// coming soon...

Please contact david.esposito@bettercloud.com if you need this documentation sooner than later.

License

The MIT License (MIT)

Copyright (c) 2016 BetterCloud

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Other Notes

Please contact david.esposito@bettercloud.com with any questions, or create an issue on Github with any bugs or feature requests.