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. The optional visualizer feature introduces a real-time, web browser display of the metrics associated with your KafkaJS client.
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.
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
- Web browser visualizer displays consumer metrics in real-time
- Secure token access and developer-friendly interface
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
-
Visualization takes you through the optional feature set-up for web browser visual display of your KafkaJS Client metrics
Install the kafkajs-metrics-visualize package from npm
npm install kafkajs-metrics-visualize
KafkaJSMetrics works with your existing KafkaJS client. More information about KafkaJS at kafka.js.org.
- Require KafkaJSMetrics in your KafkaJS Client file to access metricize function
-
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
- Run your KafkaJS Client file (skip this step if you are planning use the visualizer)
node client.js
Visit the docs for a full list of available logging methods
Example:
Prints to console:
Visit the docs for a full list of available breakpoint alert methods
Example:
Prints to console:
The following steps will allow you to access the web browser visualizer to display metrics. This visualizer is an optional feature and will not affect the library performance.
- Open the KafkaJSMetrics webpage. Click on the visualizer tab and generate a new token
-
Copy the token and head back to your KafkaJS client file. Inside the metricize function, add two additional arguments:
- first argument is the boolean value true
- second argument is your copied token
- Run your KafkaJS Client file
node client.js
- Back in the browser, click authenticate to access your web browser metrics display
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.
-
Fork this repo of KafkaJSMetrics and then clone it to your machine
-
Check out into the branch that you want to make contributions in
-
Contributions to the website and/or visualizer:
git checkout visualizer
-
Contributions to the library:
git checkout library
-
-
Create a feature branch
git checkout -b [feature/AmazingFeature]
- Add all your changes with the add command
git add [all your changes]
- Commit all your changes
git commit -m '<your comment>'
-
Make sure the visualizer OR library branch is up to date
- Check back out to the visualizer OR library branch
git checkout visualizer [OR] library
- Pull down the latest version
git pull origin visualizer [OR] library
- Check back out to your feature branch
git checkout [feature/AmazingFeature]
-
Merge your branch with visualizer OR library
git merge visualizer [OR] library
- Resolve any merge conflicts
- Run unit tests and make sure all tests pass
npm test
- Push up your branch with the command
git push origin [feature/AmazingFeature]
- Finally, open a pull request for us to review!
- Rebecca Anderson - GitHub | LinkedIn
- Paul Davey - GitHub | LinkedIn
- Ranan Hui - GitHub | LinkedIn
- Amanda Smith - GitHub | LinkedIn
- Josh Tesoro - GitHub | LinkedIn
Important links:
- Full Documentation
- Website and Visualizer
- Check out our latest Medium article
KafkaJSMetrics and KafkaJSMetrics Visualizer are 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.