Skip to main content

esque - an operational kafka tool.

Project description

esque - an operational Kafka tool

pypi Version Python Versions Build Status Coverage Status License: MIT

In the Kafka world nothing is easy, but esque (pronounced esk) is an attempt at it.

esque is a user-centric command line interface for Kafka administration.

Why should you care?

Some stuff is hard, and that is okay, but listing your kafka topics shouldn't be.

While adopting kafka at real.digital we noticed the immense entry barrier it poses to newcomers. We can't recount how often we wrote Slack messages asking for the script to check the status of topics or consumer groups. This is partly (but not only) due to a fragmented and unclear definition of tooling and APIs for kafka. In a wide array of administration tools, esque distances itself by striving to provide Kafka Ops for Humans, in a usable and natural way.

We feel that the goal of esque embodies the principle: “keep easy things easy, and make hard things possible”.

Principles

  • batteries included
  • feature rich
  • robust
  • insightful
  • by engineers for engineers

Feature Overview

  • Support for any type of Kafka deployment >1.2
  • Display Resources (Topics, Consumer Groups, Brokers)
  • Get detailed Overviews of Resources (Topics, Consumer Groups, Brokers)
  • Create/Delete Topics
  • Edit Topic Configurations
  • Edit Consumer Offset for Topics
  • SASL/SSL Support out of the box
  • Consume and Produce to and from Avro and Plaintext Topics (including Avro Schema Resolution from Schema Registry)
  • Context Switch (Easily Switch between pre-defined Clusters)
  • Kafka Ping (Test roundtrip time to your kafka cluster)

Command Overview

$ esque
Usage: esque [OPTIONS] COMMAND [ARGS]...

  esque - an operational kafka tool.

  In the Kafka world nothing is easy, but esque (pronounced esk) is an
  attempt at it.

Options:
  --version      Show the version and exit.
  -v, --verbose  Return stack trace on error.
  --no-verify    Skip all verification dialogs and answer them with yes.
  --help         Show this message and exit.

Commands:
  apply      Apply a set of topic configurations.
  config     Configuration-related options.
  consume    Consume messages from a topic.
  create     Create a new instance of a resource.
  ctx        List contexts and switch between them.
  delete     Delete a resource.
  describe   Get detailed information about a resource.
  edit       Edit a resource.
  get        Get a quick overview of different resources.
  io         Run a message pipeline.
  ping       Test the connection to the kafka cluster.
  produce    Produce messages to a topic.
  set        Set resource attributes.
  urlencode  Url-encode the given value.

Installation and Usage

Installation

esque is available at pypi.org and can be installed with pip install esque.

esque requires Python 3.8+ to run (Python 3.11 is not yet supported).

Installation on Alpine Linux

There are no wheels for Alpine Linux, so esque requires a few extra dependencies to build them during installation.

apk add python3-dev py3-pip librdkafka librdkafka-dev g++

Installation on Apple Silicon

The installation for Kafka is slightly different for Apple Silicon devices, so simply running pip install esque may result in errors.

The fix for this is to first install the librdkafka library with brew install librdkafka (make note of which version is installed). Then, add the following to the .zshrc file with the correct version of librdkafka:

export C_INCLUDE_PATH=/opt/homebrew/Cellar/librdkafka/X.X.X/include/
export LIBRARY_PATH=/opt/homebrew/Cellar/librdkafka/X.X.X/lib/

After starting a new shell (or source ~/.zshrc), you will be able to install esque normally with pip.

Autocompletion

The autocompletion scripts for bash and zsh can be generated by running esque config autocomplete.

Usage

Config Definition

When starting esque for the first time the following message will appear:

No config provided in ~/.esque
Should a sample file be created in ~/.esque [y/N]:

When answering with y esque will copy over the sample config to ~/.esque/esque_config.yaml. Afterwards you can modify that file to fit your cluster definitions.

Alternatively might just provide a config file following the sample config's file in that path.

Config Example
version: 1
current_context: local
contexts:
  # This context corresponds to a local development cluster
  # created by docker-compose when running esque from the host machine.
  local:
    bootstrap_servers:
      - localhost:9092
    security_protocol: PLAINTEXT
    schema_registry: http://localhost:8081
    default_values:
      num_partitions: 1
      replication_factor: 1

Config file for "apply" command

The config for the apply command has to be a yaml file and is given with the option -f or --file.

In the current version only topic configurations can be changed and specified.

It has to use the same schema, which is used for the following example:

topics:
  - name: topic_one
    replication_factor: 3
    num_partitions: 50
    config:
      cleanup.policy: compact
  - name: topic_two
    replication_factor: 3
    num_partitions: 50
    config:
      cleanup.policy: compact

Development

To setup your development environment, make sure you have at least Python 3.8 & poetry installed, then run

poetry install
poetry shell

Pre Commit Hooks

To install pre commit hooks run:

pip install pre-commit
pre-commit install
pre-commit install-hooks

Run tests

Integration Tests

esque comes with a docker-compose based kafka stack which you can start up with make test-suite.

You can then run the integration tests against this stack with pytest tests/ --integration --local.

Alternatively you can go the fast way and just run the whole stack + integration tests in docker:

make integration-test

Unit Tests

If you only want the unit tests, just run:

make test

Alternatives

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

esque-0.6.0.tar.gz (74.5 kB view details)

Uploaded Source

Built Distribution

esque-0.6.0-py3-none-any.whl (109.6 kB view details)

Uploaded Python 3

File details

Details for the file esque-0.6.0.tar.gz.

File metadata

  • Download URL: esque-0.6.0.tar.gz
  • Upload date:
  • Size: 74.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.8.17 Linux/5.15.0-1041-azure

File hashes

Hashes for esque-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f85e7927047a0fae295012e2b21578a89b17e6f00c8bfc7189cde1b3186fce84
MD5 a6fd8e40da5f2023a1aff9d815e7a894
BLAKE2b-256 a571dc73cec958132ec37e432e6ecb2524c378b62fb5238114d532434edc9339

See more details on using hashes here.

File details

Details for the file esque-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: esque-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 109.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.8.17 Linux/5.15.0-1041-azure

File hashes

Hashes for esque-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9aa74e1b5e0b9b1709e760a2562d3a17fd18d0b0c9dfbabde9af9feff1751327
MD5 194413f19bea972f94d297f80db68e0c
BLAKE2b-256 b0aa7e0fded19c7e18db0352bb13816119e22faee7865422e6481578865b8c81

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page