1.0.0 • Published 1 year ago

kafkajs-metrics v1.0.0

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
1 year ago

KafkaJSMetrics

A lightweight KafkaJS library that provides simple access to key metrics within your code. KafkaJSMetrics enables custom breakpoint alerts and logging of key metrics, allowing for client health to be monitored within applications.

Table of Contents

Introduction

Apache Kafka is a distributed event streaming platform that is designed to handle high performance data pipelines in real-time. KafkaJS is a lightweight, user-friendly Apache Kafka client library that runs on Node.js, providing a simple and reliable way to produce and consume messages from Kafka clusters. Event emitters called instrumentation events are built into KafkaJS and provide information about the performance and behavior of a user's Kafka producers and consumers. These events are designed to help developers monitor and troubleshoot their Kafka applications. However, incorporating instrumentation events into code can be tedious and repetitive.

KafkaJSMetrics is a continuously-growing open source product that is designed to simplify and shorten the metric exposing processes. By committing to 100% Javascript alongside KafkaJS, the library leverages already built-in instrumentation events without relying on other third-party applications or requiring any additional installations. The library gives developers simple access to key metrics required to monitor the health of a Kafka instance.

Features

Below are some of the key features from KafkaJSMetrics. For a full explanation of library functionality, visit our docs.

Key features:

  • Access to key consumer/producer/admin metrics, including
    • offset lag
    • messages consumed
    • total number of consumer/producer/admin currently connected
    • heartbeat
    • partition assignment
    • see docs for complete metrics
  • Custom Breakpoint Alerts and On/Off metrics logging options, including

    • heartbeat monitor
    • request queue size monitor
    • request pending duration monitor
    • offset lag monitor
    • see docs for complete Breakpoint Alert and metrics logging options

For information about the web browser visualizer display feature that pairs with the kafkaJSMetrics library, visit our main visualizer branch


Getting Started

KafkaJSMetrics works with your KafkaJS client. For information on setting up your KafkaJS client, visit KafkaJS.

  • Installation and Usage walk through setting up the KafkaJSMetrics library for use within your KafkaJS Client code

Installation


Install the kafkajs-metrics package from npm

npm install kafkajs-metrics

Usage

KafkaJSMetrics works with your existing KafkaJS client. More information about KafkaJS at kafka.js.org.

  1. Require KafkaJSMetrics in your KafkaJS Client file to access metricize function

  2. Pass your KafkaJS Client instance into the metricize function (sample KafkaJS Client provided)

    • All consumer, producer, and admin instances created from this client will now have metrics and metrics-associated functionality
  1. Run your KafkaJS Client file
node client.js

Turn on logging methods

Visit the docs for a full list of available logging methods

Example:

Prints to console:

Turn on breakpoint alerts

Visit the docs for a full list of available breakpoint alert methods

Example:

Prints to console:


Community

As KafkaJSMetrics continues to grow, we welcome and encourage feedback! We are also always trying to improve our code so we actively welcome all contributions! If you would like to be a part of this product, please follow the steps below.

  1. Fork this repo of KafkaJSMetrics and then clone it to your machine
  2. Check out into the branch that you want to make contributions in

    1. Contributions to the library:

      git checkout library
  3. Create a feature branch

git checkout -b [feature/AmazingFeature]
  1. Add all your changes with the add command
git add [all your changes]
  1. Commit all your changes
git commit -m '<your comment>'
  1. Make sure the library branch is up to date

    1. Check back out to the library branch
    git checkout library
    1. Pull down the latest version
    git pull origin library
    1. Check back out to your feature branch
    git checkout [feature/AmazingFeature]
  2. Merge your branch with library

git merge library
  1. Resolve any merge conflicts
  2. Run unit tests and make sure all tests pass
npm test
  1. Push up your branch with the command
git push origin [feature/AmazingFeature]
  1. Finally, open a pull request for us to review!

Contributors


Other

Important links:

KafkaJSMetrics is licensed under the Mozilla Public License version 2.0 and are available for free. We have no affiliation with and are not endorsed by either The Apache Software Foundation or the developers of KafkaJS.


1.0.0

1 year ago