Giter VIP home page Giter VIP logo

kafka-zk-restapi's Introduction

Kafka REST API

Build Status

Overview

Kafka/ZK REST API is to provide the production-ready endpoints to perform some administration/metric task for Kafka and Zookeeper.

Following features are provided:
  • cluster/nodes/controller info describe

  • Broker List

  • Broker config get/update, dynamic config get/update/delete

  • Log dirs describe, filtered by brokers/topic/partition/logdirs

  • Topic create/delete/describe/list

  • Topic config create/update/list

  • Topic partition add and reassign, replicas movement between log directories is supported

  • Topic Partition leadership transfer back to preferred replica

  • Consumer group list/describe/delete

  • Consumer Group Lag check

  • Offset reset by earliest/latest/timestamp

  • Contents view of message by different decoder, avro is also supported

  • Schema management on Schema Registry is supported

  • Collect JMX metrics from brokers that expose JMX metrics
    More details refer to JMXCollector API Specification

  • Secure the REST API with Spring Security

API

We have also opensourced a simple but useful UI for these APIs. Please check https://github.com/gnuhpc/Kafka-zk-restapi-UI for more details.

Installation and run

First of all, Java 8 jre/jdk needed.

You can download the release package at https://github.com/gnuhpc/Kafka-zk-restapi/releases

You can get it running by unzip/untaring the distribution package, perform some configurations needed and run bin/start.sh

How to build

You can build this restapi server using maven.

  1. $ git clone https://github.com/gnuhpc/Kafka-zk-restapi.git

  2. $ cd Kafka-zk-restapi/

  3. $ mvn clean package -Dmaven.test.skip=true

After maven building, you will find zip/tar under directory: Kafka-zk-restapi/target.

New: Now we support build docker image using spotify docker-maven-plugin. A docker image named kafka-rest-springboot:latest is created after building. If you want to build your own image, modify application property files in src/main/resources first. Details refer to 'How to config'

How to config

You can get it running by unzip/untaring the distribution package and change the corresponding configuration in config directory:

Change the following settings of application-ACTIVEENV.yml:

  • kafka.brokers: kafka broker addresses.

  • kafka.schemaregistry: Schema Registry address. If not exist, just provide a random URL.

  • kafka.healthcheck.topic: Topic name for health check.

  • kafka.sasl.enable/kafka.sasl.protocol/kafka.sasl.mechanism: Set kafka.sasl.enable to true if connect to a kafka cluster that adds SASL authentication. Remember to assign JAAS config file location to JVM property java.security.auth.login.config before starting this application.

  • zookeeper.uris: zookeeper addresses.

  • jmx.kafka.jmxurl/jmx.zookeeper.jmxurl: kafka/zookeeper jmx urls. If you want to use JMX Query Filter function, you can add your own custom filter files to JMXFilterTemplate directory in project root folder. More details refer to JMXCollector API Specification

  • server.security.check/server.security.checkInitDelay/server.security.checkSecurityInterval: Security related parameters. See below: 'How to config security'

How to run

A. Pulling from Docker hub

Step 1 : Prepare a directory that contains spring application property files as a volume to mount into the container. Custom your own parameters such as Kafka/zk addresses, schema registry url, security params, etc.

Step 2 : Run the image. /XX/XX/config is the directory that noticed in Step 1.

$ docker run -p 8121:8121 -v /XX/XX/config:/app/config --env JAVA_OPTS='-Xms1g -Xmx1g' tinawenqiao/kafka-rest-springboot

Note: Make sure advertised.listeners(kafka server property) is set correctly if you access kafka from docker image.

B. Run your own docker image

$ docker run -p 8121:8121 --env JAVA_OPTS='-Xms1g -Xmx1g' tinawenqiao/kafka-rest-springboot:latest

Note: Make sure advertised.listeners(kafka server property) is set correctly if you access kafka from docker image.

C. Use the built tar/zip package

  1. $ tar -xvf kafka-zk-api-1.1.x-release-dist.tar or $ unzip kafka-zk-api-1.1.x-release-dist.zip

  2. $ cd kafka-zk-api-1.1.x-release-dist

  3. $ bin/start.sh

    Note: If connect to a kafka cluster that adds SASL authentication, add -Djava.security.auth.login.config=jaas.conf to JVM property.

Security

Public REST services without access control make the sensitive data under risk.Then we provide a simple authentication mechanism using Spring Security. In order to make the project lighter, we use yml file to store user information, not using database.

Follow the steps to enable security feature:

Step 1:Modify the application config file and set server.security.check to true.

  • server.security.check:

    • True: Add security for the API. Clients can access the API with valid username and password stored in security.yml, or the Swagger UI(http://127.0.0.1:8121/api) is only allowed to access.

    • False: All the endpoints can be accessed without authentication.

  • server.security.checkInitDelay: The number of seconds of init delay for the timing thread to check the security file.

  • server.security.checkSecurityInterval: The number of seconds of check interval for the timing thread to check the security file.

Step 2: Make sure security/security.yml exist in application root folder.

Step 3: Use user controller API to add user to security file security/security.yml.
Notice:

  • The first user should be added manually. Password need to be encoded using bcrypt before saving to the yml file.For convenience, we provide CommonUtils to encode the password.

  • No need to restart server after adding new user or update user info. Timing thread introduced in Step 1 will refresh the user list according to your settings.

Support Kafka Version Information

Currently, this rest api (master branch) supports Kafka 1.1.1 brokers. The master branch is the most active branch.

For other version of kafka rather than 1.1.1, please checkout the coresponding branch by calling the command:

URI scheme

Host : localhost:8121
BasePath : /

You can access Swagger-UI by accessing http://127.0.0.1:8121/api

  • kafka-controller : Kafka Api

  • zookeeper-controller : Zookeeper Api

  • collector-controller : JMX Metric Collector Api

  • user-controller : User management Api

Version information

Version : 1.1.1

Contact information

Contact : gnuhpc
Contact Email : [email protected]
Github : https://github.com/gnuhpc
Github : https://github.com/tinawenqiao

kafka-zk-restapi's People

Contributors

creator-art avatar dependabot[bot] avatar gnuhpc avatar leolixing avatar tinawenqiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kafka-zk-restapi's Issues

CollectionConvertor missing

Dear,
it seems CollectionConvertor.java is missing.

Should I execute maven plugin before?

Could you please help?

Error path

Hello folks 🐛

@gnuhpc Cannot run the Rest application i get this error do you have any idea about th issue
mvn clean package -Dmaven.test.skip=true
k8s@ubuntu:~/Desktop/Kafka-zk-restapi$ bash target/classes/bin/start.sh
chmod: cannot access '/home/k8s/Desktop/Kafka-zk-restapi/target/classes/logs': No such file or directory
Error: Unable to access jarfile /home/k8s/Desktop/Kafka-zk-restapi/target/classes/lib/kafka*-rest-springboot*.jar

support for version 1.0.0

Is there any view of support for 1.0.0 in the near future? What are the restrictions or obstacles that prevent this being used with kafka version 1.0.0 or higher?

Question: rest api deployment

hello folks
My question is about the deployment of the rest api, it should be in the same kafka cluster or we could deploy it externaly in other vm thanks in advavce

Marking the coordinator dead error

Setup the tool for a brand new kafka cluster and I started receiving pile of these errors continuously. Not sure if I am missing something.

2019-02-28 22:06:19 INFO AbstractCoordinator:326 - (Re-)joining group kafka-zk-rest
2019-02-28 22:06:19 INFO AbstractCoordinator:542 - Marking the coordinator xx.xx.xx.xxx:9092 (id: 2147483645 rack: null) dead for group kafka-zk-rest
2019-02-28 22:06:19 INFO AbstractCoordinator:505 - Discovered coordinator xx.xx.xx.xxx:9092 (id: 2147483645 rack: null) for group kafka-zk-rest.
2019-02-28 22:06:19 INFO AbstractCoordinator:326 - (Re-)joining group kafka-zk-rest
2019-02-28 22:06:19 INFO AbstractCoordinator:542 - Marking the coordinator xx.xx.xx.xxx:9092 (id: 2147483645 rack: null) dead for group kafka-zk-rest
2019-02-28 22:06:20 INFO AbstractCoordinator:505 - Discovered coordinator xx.xx.xx.xxx:9092 (id: 2147483645 rack: null) for group kafka-zk-rest.
2019-02-28 22:06:20 INFO AbstractCoordinator:326 - (Re-)joining group kafka-zk-rest
2019-02-28 22:06:20 INFO AbstractCoordinator:542 - Marking the coordinator xx.xx.xx.xxx:9092 (id: 2147483645 rack: null) dead for group kafka-zk-rest

Docker version

Hello , maybe someone already wrote a Kafka-zk-restapi dockerFile or even in docker-compose configuration ?

Error creating topic with symbols "." and "_" in topic name

When I try to create a topic named " test.another", I get a response from the API as follows:

{
  "test.another": {
    "state": "failure",
    "msg": "Invalid topic name, it contains '.' or '_'.",
    "data": null
  }
}

However, when I try to create a topic named "test*another", I get a reply such as:

{
  "test*another": {
    "state": "failure",
    "msg": "Topic name \"test*another\" is illegal, it contains a character other than ASCII alphanumerics, '.', '_' and '-'",
    "data": null
  }
}

This message contradicts the first.

Presence of delimiters in the format"."and" _ " is convenient for a large number of topics to combine them into conditional groups.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.