Skip to content

hoptical/grafana-kafka-datasource

Repository files navigation

Kafka Datasource for Grafana

License CI Release

The Kafka data source plugin allows you to visualize streaming Kafka data from within Grafana.

Requirements

  • Apache Kafka v0.9+
  • Grafana v9.0+

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

Getting started

Installation via grafana-cli tool

Use the grafana-cli tool to install the plugin from the commandline:

grafana-cli plugins install hamedkarbasi93-kafka-datasource

The plugin will be installed into your grafana plugins directory; the default is /var/lib/grafana/plugins. More information on the cli tool.

Installation via zip file

Alternatively, you can manually download the latest release .zip file and unpack it into your grafana plugins directory; the default is /var/lib/grafana/plugins.

Configure the data source

Add a data source by filling in the following fields:

Basic Fields

Field Description
Name A name for this particular AppDynamics data source
Servers The URL of the Kafka bootstrap servers separated by comma. E.g. broker1:9092, broker2:9092

Query the Data source

To query the Kafka topic, you have to config the below items in the query editor.

Field Description
Topic Topic Name
Partition Partition Number
Auto offset reset Starting offset to consume that can be from latest or last 100.
Timestamp Mode Timestamp of the message value to visualize; It can be Now or Message Timestamp

kafka dashboard

Known limitations

  • The plugin currently does not support any authorization and authentication method.
  • The plugin currently does not support TLS.

This plugin supports topics publishing very simple JSON formatted messages. Note that only the following structure is supported as of now:

{
    "value1": 1.0,
    "value2": 2,
    "value3": 3.33,
    ...
}

We plan to support more complex JSON data structures, Protobuf and AVRO in the upcoming releases. Contributions are highly encouraged!

Sample producers

In the example folder, there are simple producers for different languages that generate json sample values in Kafka. For more details on how to run them, please check the README.md.

Contribution & development

Thank you for considering contributing! If you find an issue or have a better way to do something, feel free to open an issue or a PR. To setup the development environment, follow these steps:

Prerequisites

  • Ubuntu 24.04 LTS
  • node v22.15
  • go 1.24.1

A data source backend plugin consists of both frontend and backend components.

Frontend

  1. Install dependencies

    npm install
  2. Build plugin in development mode and run in watch mode

    npm run dev
  3. Build plugin in production mode

    npm run build
  4. Run the tests (using Jest)

    # Runs the tests and watches for changes, requires git init first
    npm run test
    
    # Exits after running all the tests
    npm run test:ci
  5. Spin up a Grafana instance and run the plugin inside it (using Docker)

    npm run server
  6. Run the E2E tests (using Playwright)

    # Spins up a Grafana instance first that we tests against
    npm run server
    
    # If you wish to start a certain Grafana version. If not specified will use latest by default
    GRAFANA_VERSION=11.3.0 npm run server
    
    # Starts the tests
    npm run e2e
  7. Run the linter

    npm run lint
    
    # or
    
    npm run lint:fix

Backend

  1. Update Grafana plugin SDK for Go dependency to the latest minor version:

    go get -u github.com/grafana/grafana-plugin-sdk-go
    go mod tidy
  2. Build backend plugin binaries for Linux:

    mage build:linux

    To build for any other platform, use mage targets:

      mage -v build:darwin
      mage -v build:windows
      mage -v build:linuxArm
      mage -v build:linuxArm64
      mage -v build:darwinArm64

    mage -v build:backend builds for your current platform.
    mage -v buildAll builds for all platforms at once.

Grafana will be available on localhost:3000 with plugin already installed.
Kafka will be available on localhost:9092 for localhost connections and on kafka:29092 for docker connections.

License

This repository is open-sourced software licensed under the Apache License 2.0.

About

A Grafana datasource plugin for Apache Kafka

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 7