卡夫卡消费者滞后指标

时间:2020-04-25 06:08:12

标签: apache-kafka kafka-producer-api

我们正在使用kafka 2.12.XXXX-需要观察消费者在一个主题的所有分区上有多少滞后。
./kafka-consumer-groups.sh --describe中的LAG列的总和是该值的准确表示吗?

1 个答案:

答案 0 :(得分:0)

是的,使用 kafka-consumer-groups.sh 脚本,您可以获取给定消费者组的消费者滞后信息。 LAG 列下的值的总和就是该特定消费者组的总滞后时间。

➜  ~ sh $KAFKA_HOME/bin/kafka-consumer-groups -bootstrap-server localhost:9092 --describe --group test-group
Consumer group 'test-group' has no active members.

TOPIC                PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID     HOST            CLIENT-ID
test-topic           0          53              53              0               -               -               -
test-topic           1          53              53              0               -               -               -

但是,我建议使用像 kt source)这样的命令行工具,因为它速度更快并且可以为您提供json输出,使用起来会更容易。

➜  ~ kt group -brokers localhost:9092 -topic test-topic -group test-group
found 1 brokers
found 1 groups
found 1 topics
found partitions=[0 1] for topic=test-topic
{
  "name": "test-group",
  "topic": "test-topic",
  "offsets": [
    {
      "partition": 0,
      "offset": 53,
      "lag": 0
    },
    {
      "partition": 1,
      "offset": 53,
      "lag": 0
    }
  ]
}

输出中的lag键是给定使用者组每个分区的使用者滞后。