Skip to content

Commit

Permalink
Renamed project: kcl -> kommitted
Browse files Browse the repository at this point in the history
  • Loading branch information
detro committed Aug 22, 2023
1 parent 991624b commit caca6ee
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 55 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "kcl"
name = "kommitted"
version = "0.1.0"
edition = "2021"
authors = [
"Ivan De Marino <detronizator@gmail.com>",
"Ivan De Marino <ivan.de.marino@gmail.com>",
"Kafkesc <https://github.com/kafkesc>",
]
repository = "https://github.com/kafkesc/kcl"
homepage = "https://github.com/kafkesc/kcl"
repository = "https://github.com/kafkesc/kommitted"
homepage = "https://github.com/kafkesc/kommitted"
description = "Measure Kafka Consumer Offset Lag and Time Lag"
license = "MIT OR Apache-2.0"
keywords = ["kafka", "consume", "lag", "monitoring", "performance"]
Expand Down
16 changes: 8 additions & 8 deletions METRICS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Metrics exposed by KCL
# Metrics exposed by Kommitted

## Metrics

### Consumer Metrics

<dl>
<dt><code>kcl_kafka_consumer_partition_lag_milliseconds</code></dt>
<dt><code>kommitted_kafka_consumer_partition_lag_milliseconds</code></dt>
<dd>
<b>Description:</b> <i>The time difference (time lag) between when the latest offset was produced and the latest consumed offset was consumed, by the consumer of the topic partition, expressed in milliseconds. NOTE: '-1, -1' means 'unknown'.</i><br/>
<b>Labels:</b> <code>cluster_id, group, topic, partition, member_id, member_host, member_client_id</code><br/>
Expand All @@ -15,7 +15,7 @@
</dl>

<dl>
<dt><code>kcl_kafka_consumer_partition_lag_offset</code></dt>
<dt><code>kommitted_kafka_consumer_partition_lag_offset</code></dt>
<dd>
<b>Description:</b> <i>The difference (lag) between the last produced offset and the last consumed offset, by the consumer of the topic partition. NOTE: '0, -1' means 'unknown'.</i><br/>
<b>Labels:</b> <code>cluster_id, group, topic, partition, member_id, member_host, member_client_id</code><br/>
Expand All @@ -25,7 +25,7 @@
</dl>

<dl>
<dt><code>kcl_kafka_consumer_partition_offset</code></dt>
<dt><code>kommitted_kafka_consumer_partition_offset</code></dt>
<dd>
<b>Description:</b> <i>The last consumed offset by the consumer of the topic partition. NOTE: '0, -1' means 'unknown'.</i><br/>
<b>Labels:</b> <code>cluster_id, group, topic, partition, member_id, member_host, member_client_id</code><br/>
Expand All @@ -37,7 +37,7 @@
### Topic Partition Metrics

<dl>
<dt><code>kcl_kafka_partition_earliest_available_offset</code></dt>
<dt><code>kommitted_kafka_partition_earliest_available_offset</code></dt>
<dd>
<b>Description:</b> <i>Earliest offset available to consumers of the topic partition.</i><br/>
<b>Labels:</b> <code>cluster_id, topic, partition</code><br/>
Expand All @@ -47,7 +47,7 @@
</dl>

<dl>
<dt><code>kcl_kafka_partition_latest_available_offset</code></dt>
<dt><code>kommitted_kafka_partition_latest_available_offset</code></dt>
<dd>
<b>Description:</b> <i>Latest offset available to consumers of the topic partition.</i><br/>
<b>Labels:</b> <code>cluster_id, topic, partition</code><br/>
Expand All @@ -59,7 +59,7 @@
### Topic Partition Offset Tracking Metrics

<dl>
<dt><code>kcl_kafka_partition_earliest_tracked_offset</code></dt>
<dt><code>kommitted_kafka_partition_earliest_tracked_offset</code></dt>
<dd>
<b>Description:</b> <i>Earliest offset tracked to estimate the lag of consumers of the topic partition.</i><br/>
<b>Labels:</b> <code>cluster_id, topic, partition</code><br/>
Expand All @@ -69,7 +69,7 @@
</dl>

<dl>
<dt><code>kcl_kafka_partition_latest_tracked_offset</code></dt>
<dt><code>kommitted_kafka_partition_latest_tracked_offset</code></dt>
<dd>
<b>Description:</b> <i>Latest offset tracked to estimate the lag of consumers of the topic partition.</i><br/>
<b>Labels:</b> <code>cluster_id, topic, partition</code><br/>
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# KCL - Kafka Consumer Lag
# Kommitted - Measure Kafka consumers lag

<div align="center" style="text-align: center;">

Measure Kafka Consumer **Offset Lag** _and_ **Time Lag**

</div>

**KCL** is a service to measure the _Lag_ (i.e. _Latency_) of Kafka consumers.
It works with all consumers that _commit_ their offsets into Kafka the
[standard way](https://kafka.apache.org/documentation/#design_consumerposition), as it
**Kommitted** is a service to measure the _Lag_ (i.e. _Latency_) of Kafka consumers.
It works with all consumers that _commit_ their offsets into Kafka (i.e. the
[standard way](https://kafka.apache.org/documentation/#design_consumerposition)), as it
consumes the internal `__consumer_offsets` topic.

Metrics are exported (at the `/metrics` endpoint, following the
[Prometheus](https://prometheus.io/)
Metrics are exported following the [Prometheus](https://prometheus.io/)
[Exposition formats](https://prometheus.io/docs/instrumenting/exposition_formats/#exposition-formats).

Please see [DESIGN.md](./DESIGN.md) for details about the overall architecture, dependencies and other details.
Expand All @@ -25,8 +24,8 @@ Please see [DESIGN.md](./DESIGN.md) for details about the overall architecture,
* [x] Offset and Lag metrics are tracked with all contextual information to identify exact topic partition assignments
* [ ] Exposes additional metrics to track status of Kafka cluster (topics, members, brokers, partitions)
* [ ] Exposes Kafka-polling metrics, to assess its own performance
* [x] Metrics exposed in [Prometheus format](https://prometheus.io/docs/instrumenting/exposition_formats/#exposition-formats)
* [ ] REST API to build further automation on top of it (eg. auto-scaling logics that depend on Consumer Group lag)
* [x] Metrics exposed in [Prometheus format](https://prometheus.io/docs/instrumenting/exposition_formats/#exposition-formats), at `/metrics` endpoint
* [ ] REST API to build further automation on top of it (e.g. auto-scaling logics that depend on Consumer Group lag)

All of this comes based on:

Expand All @@ -45,18 +44,19 @@ WIP

## Usage

KCL supports _compact_ (`-h`) and _extended_ (`--help`) usage instructions. Use the former for a quick look up;
the latter to better understand what each argument can do.
Kommitted supports _compact_ (`-h`) and _extended_ (`--help`) usage instructions.
Use the former for a quick look up; use the latter to better understand what
each argument can do.

<details open>
<summary>Compact: `kcl -h`</summary>
<summary>Compact: `kommitted -h`</summary>

```shell
Usage: kcl [OPTIONS] --brokers <BOOTSTRAP_BROKERS>
Usage: kommitted [OPTIONS] --brokers <BOOTSTRAP_BROKERS>

Options:
-b, --brokers <BOOTSTRAP_BROKERS> Initial Kafka Brokers to connect to (format: 'HOST:PORT,...')
--client-id <CLIENT_ID> Client identifier used by the internal Kafka (Admin) Client [default: kcl]
--client-id <CLIENT_ID> Client identifier used by the internal Kafka (Admin) Client [default: kommitted]
--kafka-conf <CONF_KEY:CONF_VAL> Additional configuration used by the internal Kafka (Admin) Client (format: 'CONF_KEY:CONF_VAL').
--cluster-id <CLUSTER_ID> Override identifier of the monitored Kafka Cluster
--history <SIZE> For each Topic Partition, how much history of offsets to track in memory. [default: 3600]
Expand All @@ -69,10 +69,10 @@ the latter to better understand what each argument can do.
</details>

<details>
<summary>Extended: `kcl --help`</summary>
<summary>Extended: `kommitted --help`</summary>

```shell
Usage: kcl [OPTIONS] --brokers <BOOTSTRAP_BROKERS>
Usage: kommitted [OPTIONS] --brokers <BOOTSTRAP_BROKERS>
Options:
-b, --brokers <BOOTSTRAP_BROKERS>
Expand All @@ -85,7 +85,7 @@ the latter to better understand what each argument can do.
Equivalent to '--config=client.id:my-client-id'.
[default: kcl]
[default: kommitted]
--kafka-conf <CONF_KEY:CONF_VAL>
Additional configuration used by the internal Kafka (Admin) Client (format: 'CONF_KEY:CONF_VAL').
Expand Down Expand Up @@ -129,7 +129,7 @@ the latter to better understand what each argument can do.
* '-vv' = 'DEBUG'
* '-vvv' = 'TRACE'
Alternatively, set environment variable 'KCL_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
Alternatively, set environment variable 'KOMMITTED_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
-q, --quiet...
Quiet logging.
Expand All @@ -138,7 +138,7 @@ the latter to better understand what each argument can do.
* '-q' = 'ERROR'
* '-qq' = 'OFF'
Alternatively, set environment variable 'KCL_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
Alternatively, set environment variable 'KOMMITTED_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
-h, --help
Print help (see a summary with '-h')
Expand All @@ -151,7 +151,7 @@ the latter to better understand what each argument can do.
### Connect to Kafka cluster requiring [`SASL_SSL`](https://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer)
```shell
$ kcl \
$ kommitted \
--brokers {{ BOOTSTRAP_BROKERS or BROKER_ENDPOINT }} \
--config security.protocol:SASL_SSL \
--config sasl.mechanisms=PLAIN \
Expand All @@ -174,7 +174,7 @@ Ksunami follows the long tradition of `-v/-q` to control the verbosity of it's l
| `-vvv...` | `TRACE` | |
It uses [log](https://crates.io/crates/log) and [env_logger](https://crates.io/crates/env_logger),
and so logging can be configured and fine-tuned using the Environment Variable `KCL_LOG`.
and so logging can be configured and fine-tuned using the Environment Variable `KOMMITTED_LOG`.
Please take a look at [env_logger doc](https://docs.rs/env_logger/latest/env_logger/#enabling-logging)
for more details.
Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct Cli {
/// * '-vv' = 'DEBUG'
/// * '-vvv' = 'TRACE'
///
/// Alternatively, set environment variable 'KCL_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
/// Alternatively, set environment variable 'KOMMITTED_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
#[arg(short, long, action = clap::ArgAction::Count, verbatim_doc_comment)]
pub verbose: u8,

Expand All @@ -92,7 +92,7 @@ pub struct Cli {
/// * '-q' = 'ERROR'
/// * '-qq' = 'OFF'
///
/// Alternatively, set environment variable 'KCL_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
/// Alternatively, set environment variable 'KOMMITTED_LOG=(ERROR|WARN|INFO|DEBUG|TRACE|OFF)'.
#[arg(short, long, action = clap::ArgAction::Count, verbatim_doc_comment)]
pub quiet: u8,
}
Expand Down
3 changes: 2 additions & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub(crate) const KONSUMER_OFFSETS_DATA_TOPIC: &str = "__consumer_offsets";

/// This is the Consumer Group (`group.id`) value used by
/// the Consumer inside the `konsumer_offsets_data` module.
pub(crate) const KONSUMER_OFFSETS_KCL_CONSUMER: &str = "__kcl__consumer_offsets_consumer";
pub(crate) const KOMMITTED_CONSUMER_OFFSETS_CONSUMER: &str =
"__kommitted__consumer_offsets_consumer";

/// The default host to bind to when launching internal HTTP server.
pub(crate) const DEFAULT_HTTP_HOST: &str = "localhost";
Expand Down
4 changes: 2 additions & 2 deletions src/consumer_groups/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tokio::{
};
use tokio_util::sync::CancellationToken;

use crate::constants::KONSUMER_OFFSETS_KCL_CONSUMER;
use crate::constants::KOMMITTED_CONSUMER_OFFSETS_CONSUMER;
use crate::internals::Emitter;
use crate::kafka_types::{Group, GroupWithMembers, Member, MemberWithAssignment, TopicPartition};

Expand All @@ -35,7 +35,7 @@ impl From<GroupList> for ConsumerGroups {

for g in gl.groups() {
// Ignore own consumer of `__consumer_offsets` topic
if g.name() == KONSUMER_OFFSETS_KCL_CONSUMER {
if g.name() == KOMMITTED_CONSUMER_OFFSETS_CONSUMER {
continue;
}

Expand Down
18 changes: 9 additions & 9 deletions src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,32 +216,32 @@ async fn prometheus_metrics(State(state): State<HttpServiceState>) -> impl IntoR
//
// --- CLUSTER METRICS ---
//
// TODO `kcl_consumer_groups_total`
// TODO `kommitted_consumer_groups_total`
// LABELS: cluster_id?
//
// TODO `kcl_consumer_group_members_total`
// TODO `kommitted_consumer_group_members_total`
// LABELS: cluster_id?
//
// TODO `kcl_cluster_status_brokers_total`
// TODO `kommitted_cluster_status_brokers_total`
// LABELS: cluster_id?
//
// TODO `kcl_cluster_status_topics_total`
// TODO `kommitted_cluster_status_topics_total`
// LABELS: cluster_id?
//
// TODO `kcl_cluster_status_partitions_total`
// TODO `kommitted_cluster_status_partitions_total`
// LABELS: cluster_id?
//
// --- KCL INTERNAL METRICS ---
// --- KOMMITTED INTERNAL METRICS ---
//
// TODO `kcl_consumer_groups_poll_time_seconds`
// TODO `kommitted_consumer_groups_poll_time_seconds`
// HELP: Time taken to fetch information about all consumer groups in the cluster.
// LABELS: cluster_id?
//
// TODO `kcl_cluster_status_poll_time_ms`
// TODO `kommitted_cluster_status_poll_time_ms`
// HELP: Time taken to fetch information about the composition of the cluster (brokers, topics, partitions).
// LABELS: cluster_id?
//
// TODO `kcl_partitions_watermark_offsets_poll_time_ms`
// TODO `kommitted_partitions_watermark_offsets_poll_time_ms`
// HELP: Time taken to fetch earliest/latest (watermark) offsets of all the topic partitions of the cluster.
// LABELS: cluster_id?

Expand Down
4 changes: 2 additions & 2 deletions src/konsumer_offsets_data/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rdkafka::{
use tokio::{sync::mpsc, task::JoinHandle, time::Duration};
use tokio_util::sync::CancellationToken;

use crate::constants::{KONSUMER_OFFSETS_DATA_TOPIC, KONSUMER_OFFSETS_KCL_CONSUMER};
use crate::constants::{KOMMITTED_CONSUMER_OFFSETS_CONSUMER, KONSUMER_OFFSETS_DATA_TOPIC};
use crate::internals::Emitter;

const CHANNEL_SIZE: usize = 2000;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl KonsumerOffsetsDataEmitter {
client_config.set("enable.partition.eof", "false");

if client_config.get("group.id").is_none() {
client_config.set("group.id", KONSUMER_OFFSETS_KCL_CONSUMER);
client_config.set("group.id", KOMMITTED_CONSUMER_OFFSETS_CONSUMER);
}

client_config.set_log_level(RDKafkaLogLevel::Warning);
Expand Down
8 changes: 4 additions & 4 deletions src/lag_register/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use konsumer_offsets::{GroupMetadata, KonsumerOffsetsData, OffsetCommit};
use log::Level::Trace;
use tokio::sync::{mpsc, RwLock};

use crate::constants::KONSUMER_OFFSETS_KCL_CONSUMER;
use crate::constants::KOMMITTED_CONSUMER_OFFSETS_CONSUMER;
use crate::consumer_groups::ConsumerGroups;
use crate::internals::Awaitable;
use crate::kafka_types::{Group, Member, TopicPartition};
Expand Down Expand Up @@ -130,7 +130,7 @@ async fn process_consumer_groups(
) {
for (group_name, group_with_members) in cg.groups.into_iter() {
// Ignore own consumer of `__consumer_offsets` topic.
if group_name == KONSUMER_OFFSETS_KCL_CONSUMER {
if group_name == KOMMITTED_CONSUMER_OFFSETS_CONSUMER {
continue;
}

Expand Down Expand Up @@ -203,7 +203,7 @@ async fn process_offset_commit(
po_reg: Arc<PartitionOffsetsRegister>,
) {
// Ignore own consumer of `__consumer_offsets` topic.
if oc.group == KONSUMER_OFFSETS_KCL_CONSUMER {
if oc.group == KOMMITTED_CONSUMER_OFFSETS_CONSUMER {
return;
}

Expand Down Expand Up @@ -268,7 +268,7 @@ async fn process_group_metadata(
lag_register_groups: Arc<RwLock<HashMap<String, GroupWithLag>>>,
) {
// Ignore own consumer of `__consumer_offsets` topic.
if gm.group == KONSUMER_OFFSETS_KCL_CONSUMER {
if gm.group == KOMMITTED_CONSUMER_OFFSETS_CONSUMER {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/logging.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub const LOG_FILTER_ENV_VAR: &str = "KCL_LOG";
pub const LOG_FILTER_ENV_VAR: &str = "KOMMITTED_LOG";

/// Log level will be configured based on the given `verbosity_level`.
///
/// If the env var `KCL_LOG` is set, that will take precedence and configuration
/// If the env var `KOMMITTED_LOG` is set, that will take precedence and configuration
/// will be based on the rules described [here](https://docs.rs/env_logger/latest/env_logger/#enabling-logging).
pub fn init(verbosity_level: i8) {
let default_log_level = match verbosity_level {
Expand Down
2 changes: 1 addition & 1 deletion src/prometheus_metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;

use prometheus::Registry;

pub const NAMESPACE: &str = "kcl";
pub const NAMESPACE: &str = "kommitted";

pub const LABEL_CLUSTER_ID: &str = "cluster_id";
pub const LABEL_GROUP: &str = "group";
Expand Down

0 comments on commit caca6ee

Please sign in to comment.