Plugins 〉Kafka


Developer

Hamed Karbasi

Sign up to receive occasional product news and updates:



Data Source
community

Kafka

  • Overview
  • Installation
  • Change log
  • Related content

Kafka Datasource for Grafana

License CI Release Go Version Grafana v10.2+ Go Report Card


Visualize real-time Kafka data in Grafana dashboards.


Why Kafka Datasource?

  • Live streaming: Monitor Kafka topics in real time.
  • Flexible queries: Select topics, partitions, offsets, and timestamp modes.
  • Rich JSON support: Handles flat, nested, and array data.
  • Avro support: Integrates with Schema Registry for Avro messages.
  • Secure: SASL authentication & SSL/TLS encryption.
  • Easy setup: Install and configure in minutes.

How It Works

This plugin connects your Grafana instance directly to Kafka brokers, allowing you to query, visualize, and explore streaming data with powerful time-series panels and dashboards.

Requirements

  • Apache Kafka v0.9+
  • Grafana v10.2+

Note: This is a backend plugin, so the Grafana server should have access to the Kafka broker.

Features

  • Real-time monitoring of Kafka topics
  • Kafka authentication (SASL) & encryption (SSL/TLS)
  • Query all or specific partitions
  • Autocomplete for topic names
  • Flexible offset options (latest, last N, earliest)
  • Timestamp modes (Kafka event time, dashboard received time)
  • Advanced JSON support (flat, nested, arrays, mixed types)
  • Avro support with Schema Registry integration (inline schema or Schema Registry)
  • Protobuf support with Schema Registry integration (inline schema or Schema Registry)
  • Message key support (None, String, JSON, Base64 formats)
  • Configurable flattening depth (default: 5)
  • Configurable max fields per message (default: 1000)
  • Customizable query aliases with placeholders

Installation

Via grafana-cli

grafana-cli plugins install hamedkarbasi93-kafka-datasource

Via zip file

Download the latest release and unpack it into your Grafana plugins directory (default: /var/lib/grafana/plugins).

Provisioning

You can automatically configure the Kafka datasource using Grafana's provisioning feature. For a ready-to-use template and configuration options, refer to provisioning/datasources/datasource.yaml in this repository.

Usage

Configuration

  1. Add a new data source in Grafana and select "Kafka Datasource".
  2. Configure connection settings:
    • Broker address (e.g. localhost:9094 or kafka:9092)
    • Authentication (SASL, SSL/TLS, optional)
    • Avro Schema Registry (if using Avro format)
    • Timeout settings (default: two seconds)

Build the Query

  1. Create a new dashboard panel in Grafana.
  2. Select your Kafka data source.
  3. Configure the query:
    • Topic: Enter or select your Kafka topic (autocomplete available).
    • Fetch Partitions: Click to retrieve available partitions.
    • Partition: Choose a specific partition or "all" for all partitions.
    • Message Format:
      • JSON: For JSON messages
      • Avro: For Avro messages (requires schema registry or inline schema)
      • Protobuf: For Protobuf messages (requires schema registry or inline schema)
    • Offset Reset:
      • latest: Only new messages
      • last N messages: Start from the most recent N messages (set N in the UI)
      • earliest: Start from the oldest message
    • Timestamp Mode: Choose between Kafka event time or dashboard received time.
    • Alias: Optional custom name for the query series. Supports template placeholders:
      • {{topic}}: The Kafka topic name
      • {{field}}: The field name (for field display names)
      • {{partition}}: The partition number
      • {{refid}}: The query RefID (e.g., A, B)
    • Key Format: Choose how to process Kafka message keys:
      • None: Ignore keys (default, backward compatible)
      • String: Single "key" column with UTF-8 decoded key
      • JSON: Flatten JSON keys with "key." prefix (e.g., key.userId, key.region)
      • Base64: Single "key" column with raw binary key encoded as a base64 string

Tip: Numeric fields become time series, string fields are labels, arrays and nested objects are automatically flattened for visualization.

Supported JSON Structures

  • Flat objects
  • Nested objects (flattened)
  • Top-level arrays
  • Mixed types

Examples:

Simple flat object:

{
  "temperature": 23.5,
  "humidity": 65.2,
  "status": "active"
}

Nested object (flattened as user.name, user.age, settings.theme):

{
  "user": {
    "name": "John Doe",
    "age": 30
  },
  "settings": {
    "theme": "dark"
  }
}

Top-level array (flattened as item_0.id, item_0.value, item_1.id, etc.):

[
  { "id": 1, "value": 10.5 },
  { "id": 2, "value": 20.3 }
]

Avro Support

Avro messages are supported using either:

  • Inline schema: paste your Avro schema (JSON format) in the UI
  • Schema Registry: the plugin fetches the latest schema by subject from the configured Schema Registry

Example Avro schema:

{
  "type": "record",
  "name": "SensorReading",
  "fields": [
    { "name": "sensor_id", "type": "string" },
    { "name": "temperature", "type": "double" },
    { "name": "timestamp", "type": "long" }
  ]
}

Both flat and nested structures are supported. When using Schema Registry, messages are encoded in Confluent wire format with schema ID prefix for efficient deserialization.

Protobuf Support

Protobuf messages are supported using either:

  • Inline schema: paste your .proto schema definition in the UI
  • Schema Registry: the plugin extracts the schema ID from the Confluent wire format header and fetches the schema from the configured Schema Registry

Example Protobuf schema:

syntax = "proto3";

message SensorReading { string sensor_id = 1; double temperature = 2; int64 timestamp = 3; }

Both flat and nested structures are supported. Confluent wire format uses a magic byte (0x00) followed by a 4-byte schema ID, then a variable-length message-indexes array (varint-encoded), and finally the Protobuf payload. The message-indexes identify which message type in the schema the payload encodes.

Known Protobuf Limitations

  • Inline schemas do not support imports
    • Well-known types like google.protobuf.Timestamp won't compile when provided inline
    • Use inline schema for simple schemas, or provide the schema via Schema Registry if imports are needed
  • Default message selection: the first top-level message in the .proto file is used as the default
  • Schema caching: schemas are cached by ID/subject to avoid repeated registry requests

If you encounter issues with complex Protobuf schemas, open an issue so we can prioritize improvements.

Live Demo

Kafka dashboard

Sample Data Generator

Want to test the plugin with realistic Kafka messages? Use the included sample producers to generate JSON, Avro, or Protobuf messages with various structures and schema configurations. For detailed usage, see the example README. The producers support flexible options for message format, structure, intervals, and schema registry integration.

FAQ & Troubleshooting

  • Can I use this with any Kafka broker? Yes, supports Apache Kafka v0.9+ and compatible brokers.
  • Does it support secure connections? Yes, SASL and SSL/TLS are supported.
  • What JSON formats are supported? Flat, nested, arrays, mixed types.
  • How do I generate test data? Use the included Go or Python producers.
  • Where do I find more help? See this README or open an issue.

Documentation & Links


Support & Community

If you find this plugin useful, please consider giving it a ⭐ on GitHub or supporting development:

Buy Me a Coffee

For more information, see the documentation files above or open an issue/PR.

Installing Kafka on Grafana Cloud:

For more information, visit the docs on plugin installation.

Changelog

v1.5.1

Full Changelog

  • Chore: bump go, grafana-plugin-sdk and transitive packages to fix security vulnerabilities (#136)
  • Feat: add support for the breaking change of the live server in Grafana v12.4 (#135)

v1.5.0

Full Changelog

  • Fix: cleanup Kafka connections, tighten logging, propagate context & use theme spacing in QueryEditor (#133)
  • Feat: add support for json, string and binary message keys (#132)

v1.4.0

Full Changelog

  • Feat: add Protobuf Support (#128)
  • Chore: bump @grafana/create-plugin configuration to 6.8.4 (#129)
  • Feat: improve backend tests to increase coverage and reliability (#130)
  • Feat: update backend and frontend packages to fix security vulnerabilities (#130)

v1.3.0

Full Changelog

  • Enhancement: Upgrade dependencies to address security vulnerabilities (#126)
  • Fix: Improve SASL defaulting, error clarity, and health check timeout handling (#123)
  • Feat: Add support for refid and alias in queries (#122)
  • Fix: Multiple query support by making streaming stateless (#121)

v1.2.3

Full Changelog

  • Enhancement: Change info levels to debug for all requests in the backend (#118)

v1.2.2

Full Changelog

  • Feat: Add PDC support for schema registry using grafana-plugin-sdk-http-client (#113)
  • Enhancement: Add linting for frontend and backend with pre-commit hooks and CI updates (#115)
  • Enhancement: Replace inline styling with emotion styling and update related tests (#116)

v1.2.1

Full Changelog

  • Refactor: Improve e2e test stability and maintainability (#112)

v1.2.0

Full Changelog

  • Feat: Implement Avro support (#96) — add Avro parsing and support for Avro-encoded messages in the plugin.
  • Chore: Bump @grafana/create-plugin configuration to 6.4.3 (#109)

v1.1.0

Full Changelog

  • Fix: Address security issues in dependencies and configuration (#107)
  • Fix: Use type registry with nullable types to prevent data loss when encountering null values (#104)
  • Perf: Pre-allocate frame fields to eliminate append overhead (#106)
  • Feat: Configurable JSON flatten limits (#99)
  • Add: Provisioned dashboard (#94)
  • Fix: Mutation issue in config editor and query editor (#91)
  • Fix: e2e tests for query editor for Grafana versions later than 12.2 (#102)
  • Add: Devcontainer for development (#90)
  • Test: Improve mutation tests with deep freezing (#93)
  • CI: Skip publish-report for fork PRs (#103)

v1.0.1

Full Changelog

  • Restructure and split documentation (README, docs/development.md, docs/contributing.md, docs/code_of_conduct.md)
  • Add “Create Plugin Update” GitHub Action
  • Add release workflow pre‐check to ensure tag exists in CHANGELOG
  • Bump plugin and package versions to 1.0.1

v1.0.0 (2025-08-14)

Full Changelog

  • Add support for the nested JSON #83 (hoptical)
  • Support for Nested JSON via Automatic Flattening #79

v0.6.0 (2025-08-13)

Full Changelog

  • Use kafka message time as default option #82 (hoptical)

  • Add options to auto offset reset #81 (hoptical)

  • Add/support all partitions #80 (hoptical)

  • Topic Selection with Autocomplete #78

  • Improve the offset reset field #76

  • Add support for selecting all partitions #75

  • Is it possible to reset offset? #47

  • Clarify the options of the timestamp mode #77

v0.5.0 (2025-08-01)

Full Changelog

v0.4.0 (2025-07-19)

Full Changelog

v0.3.0 (2025-05-24)

Full Changelog

  • Fix/release #65 (hoptical)

  • Fix/streaming logic #64 (hoptical)

  • add value-offset to go producer example #63 (hoptical)

  • Update/grafana go sdk #62 (hoptical)

  • Add/golang example #60 (hoptical)

  • Add/redpanda console #58 (hoptical)

  • Add Kafka to docker compose #54 (sizovilya)

  • [BUG] Cannot connect to the brokers #55

  • [BUG] Plugin Unavailable #45

  • plugin unavailable #44

  • [BUG] 2 Kafka panels on 1 dashboard #39

  • [BUG] The yarn.lock is out of sync with package.json since the 0.2.0 commit #35

  • User has to refresh page to trigger streaming #28

  • Mage Error #6

  • use access policy token instead of the legacy one #66 (hoptical)

  • Fix switch component #61 (sizovilya)

  • Change Kafka driver #57 (sizovilya)

  • Provide default options to UI #56 (sizovilya)

  • Fix CI Failure #53 (hoptical)

  • Add developer-friendly environment #52

  • Migrate from Grafana toolkit #50

  • Can you make an arm64-compatible version of this plugin? #49

  • Add Authentication & Authorization Configuration #20

  • Migrate from toolkit #51 (sizovilya)

  • Update README.md #46 (0BVer)

  • Add support for using AWS MSK Managed Kafka #38 (ksquaredkey)

  • Issue 35 update readme node14 for dev (#1) #37 (ksquaredkey)

v0.2.0 (2022-07-26)

Full Changelog

v0.1.0 (2021-11-14)

Full Changelog