【问题标题】:Kafka consumer lag metricKafka 消费者滞后指标
【发布时间】:2020-08-08 19:26:37
【问题描述】:

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

【问题讨论】:

    标签: apache-kafka kafka-producer-api


    【解决方案1】:

    是的,使用 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 键是给定消费者组的每个分区的消费者滞后。

    【讨论】:

    • @IUnknown 这能回答你的问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多