kafka-lag-script
v2.0.1
Published
The script that determines and sends Slack messages about our current consumer lags.
Downloads
6
Maintainers
Readme
Kafka Lag Monitoring Script
This script is designed to monitor the lag of Kafka consumer groups and send notifications to a Slack webhook if a significant lag is detected.
Usage
To use this script, you need to provide the following configurations:
Kafka Configuration:
clientId
(string): The client ID for the Kafka connection.brokers
(string[]): An array of Kafka broker URLs.sasl
(optional, SASLConfig): The SASL configuration for authentication, if required.ssl
(optional, boolean, default: true): Whether to use SSL for the Kafka connection.connectionTimeout
(optional, number, default: 100000): The connection timeout in milliseconds.
Slack Configuration:
webHookUrl
(string): The Slack webhook URL for sending notifications.tokenConfig
(optional, object): Additional token configuration for the Slack API, if required.
Namespace Filter (optional):
name_space
(string[] ): An array of namespace strings to filter the consumer groups. If provided, only consumer groups with the specified namespaces will be monitored.
Example usage:
import { initRunner,SASLConfig } from 'kafka-lag-script';
const saslConfig:SASLConfig={
mechanism: 'scram-sha-512',
username: 'my-username',
password: 'my-password'
}
const kafkaConfig = {
clientId: 'my-client-id',
brokers: ['broker1:9092', 'broker2:9092'],
sasl: saslConfig
};
const slackConfig = {
webHookUrl: 'https://hooks.slack.com/services/...',
tokenConfig: {
channelName: 'channel_xyz',
tokenId: 'xoxb-...'
}
};
const namespaces = ['NAMESPACE1', 'NAMESPACE2'];
initRunner(kafkaConfig, slackConfig, namespaces);