How to Run Kafdrop – Kafka Web UI in Docker and Docker Compose

Run Kafdrop, the lightweight Kafka web UI, in Docker and Docker Compose. Browse topics, consumer groups, and messages with a simple UI.

Kafdrop is a lightweight web UI for viewing Apache Kafka topics, consumer groups, and messages. It shows brokers, partitions, replication status, and lets you browse or create topics without using the Kafka CLI.

Apache Kafka is an open-source event streaming platform (originally developed at LinkedIn, now an Apache project) that can handle over a million messages per second. It does not ship with a built-in UI, so inspecting topics and consumer lag usually means using command-line tools. Kafdrop fills that gap with a simple, browser-based interface you can run in Docker or Docker Compose alongside your Kafka cluster.

Features

  • View Kafka brokers - topic and partition assignments, and controller status
  • View topics - partition count, replication status, and custom configuration
  • Browse messages - JSON, plain text, Avro and Protobuf encoding
  • View consumer groups – per-partition committed offsets and lag
  • Create new topics
  • View ACLs
  • Support for Azure Event Hubs

Related posts:

Prerequisites

Running Kafdrop with Docker

Run Kafdrop as a container that connects to Kafka on 127.0.0.1:9092. Map the container port 9000 to host port 9080 so you can open the UI in your browser.

1
2
3
4
5
docker run -d --rm -p 9080:9000 \
    -e KAFKA_BROKERCONNECT=127.0.0.1:9092 \
    -e JVM_OPTS="-Xms32M -Xmx64M" \
    -e SERVER_SERVLET_CONTEXTPATH="/" \
    obsidiandynamics/kafdrop:latest

Verify the container is running:

1
2
3
$ docker ps
CONTAINER ID   IMAGE                              COMMAND                  CREATED         STATUS         PORTS                                                             NAMES
c95749e59649   obsidiandynamics/kafdrop:latest    "/kafdrop.sh"            3 minutes ago   Up 3 minutes   0.0.0.0:9080->9000/tcp, :::9080->9000/tcp                         exciting_boy

Open the Kafdrop UI at http://localhost:9080 or http://<server_ip>:9080. If you access it from another machine, allow port 9080 through your firewall (e.g. sudo ufw allow 9080/tcp && sudo ufw reload).

Running with Protobuf descriptors

If your messages use Protobuf encoding, mount the descriptor files and enable the Protobuf format:

1
2
3
4
5
6
docker run -d --rm -v <path_to_protobuf_descriptor_files>:/var/protobuf_desc -p 9000:9000 \
    -e KAFKA_BROKERCONNECT=<host:port,host:port> \
    -e JVM_OPTS="-Xms32M -Xmx64M" \
    -e SERVER_SERVLET_CONTEXTPATH="/" \
    -e CMD_ARGS="--message.format=PROTOBUF --protobufdesc.directory=/var/protobuf_desc" \
    obsidiandynamics/kafdrop

Running Kafdrop with Docker Compose

Use Docker Compose to run Kafdrop and Kafka (with Zookeeper) together. Create a docker-compose.yaml file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
services:
  kafdrop:
    image: obsidiandynamics/kafdrop:latest
    ports:
      - 9080:9000
    environment:
      KAFKA_BROKERCONNECT: kafka:29092
      JVM_OPTS: "-Xms16M -Xmx48M -Xss180K -XX:-TieredCompilation -XX:+UseStringDeduplication -noverify"
      SERVER_SERVLET_CONTEXTPATH: "/"
    depends_on:
      - kafka

  kafka:
    image: obsidiandynamics/kafka:latest
    ports:
      - "2181:2181"
      - "9092:9092"
    environment:
      KAFKA_LISTENERS: "INTERNAL://:29092,EXTERNAL://:9092"
      KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka:29092,EXTERNAL://localhost:9092"
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT"
      KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL"
      KAFKA_ZOOKEEPER_SESSION_TIMEOUT: "6000"
      KAFKA_RESTART_ATTEMPTS: "10"
      KAFKA_RESTART_DELAY: "5"
      ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL: "0"

Start the stack with Docker Compose v2 (docker compose) or v1 (docker-compose):

1
docker compose up -d

Or:

1
docker-compose up -d

Check that both services are up:

1
docker compose ps

Open a browser and go to http://localhost:9080 or http://<server_ip>:9080.

Cluster Overview

The landing page is the Cluster Overview. You see the layout of the cluster, each broker’s address, whether it is the controller, and how many partitions it owns. As the cluster and number of topics grow, aim for a roughly even distribution of partitions across brokers.

Topics list

The Topics list is searchable and shows each topic’s partition count, replication, and config. Watch the under-replicated column: it should be zero. Non-zero values mean some partition replicas have fallen behind and may indicate a broker or network issue.

Click a topic to open the Topic Overview.

Topic overview

The Topic Overview has four areas:

  • Top-left: Topic stats (similar to the cluster overview).
  • Top-right: Custom topic configuration (if any overrides are set).
  • Bottom-left: Partitions; each partition index is a link that opens the first 100 messages for that partition.
  • Bottom-right: Consumers – consumer group names and aggregate lag (sum of partition lags).

Click a consumer group to open the Consumer View, which shows committed offsets and lag per partition per topic.

Message view

The Message View lists messages (records) for a chosen partition in order. You can open it by:

  1. Clicking View Messages in the Topic Overview, or
  2. Clicking a partition link in the Topic Overview.

Each message shows offset, key (if set), timestamp, and headers. If the payload is valid JSON, Kafdrop can format it when you expand the message (green arrow on the left).

Verifying the setup

  • Docker: docker ps should show the Kafdrop container listening on 9080.
  • Compose: docker compose ps (or docker-compose ps) should show kafdrop and kafka (and Zookeeper if applicable) as running.
  • UI: Opening http://localhost:9080 should show the Cluster Overview; if Kafka is unreachable, you may see connection errors until the broker is up and reachable.

Summary

You can run Kafdrop either as a standalone Docker container (pointing KAFKA_BROKERCONNECT at your existing Kafka) or with Docker Compose alongside Kafka and Zookeeper. Use the UI to inspect brokers, topics, consumer groups, and messages, and to create or delete topics as needed.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy