• kafka监控指标项


    监控配置

    ​ kafka基本分为broker、producer、consumer三个子项,每一项的启动都需要用到 $KAFKA_HOME/bin/kafka-run-class.sh 脚本,在该脚本中,存在以下语句:

    if ...
      KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false"
    fi
    if ...
      KAFKA_JMX_OPTS="$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
    fi
    

    ​ 在启动kafka的过程中,只要指定 JMX_PORT 的值,即可对broker、producer、consumer进行监控。目前有两种方法,

    • $KAFKA_HOME/bin/kafka-server-start.sh$KAFKA_HOME/bin/kafka-console-consumer.sh$KAFKA_HOME/bin/kafka-console-producer.sh 三个脚本中分别添加 $JMX_PORT=XXXX 语句,但是只适用于使用console方式对topic进行使用的情况。
    • 修改$KAFKA_HOME/bin/kafka-run-class.sh 脚本中的上述语句,使其端口随机变化,可以通过 ps -ef |grep kafka 命令来获取随机的端口号,来进行监控

    指标项来源

    以下端口均随机获得。

    主机名 类别 端口号
    192.168.20.10 broker 9183
    192.168.20.10 producer 9108
    192.168.20.10 consumer 9173

    kafka监控项

    OS监控项

    objectName 指标项 说明
    java.lang:type=OperatingSystem FreePhysicalMemorySize 空闲物理内存
    java.lang:type=OperatingSystem SystemCpuLoad 系统CPU利用率
    java.lang:type=OperatingSystem ProcessCpuLoad 进程CPU利用率
    java.lang:type=GarbageCollector,
    name=G1 Young Generation
    CollectionCount GC次数

    broker指标

    objectName 指标项 说明
    kafka.server:type=BrokerTopicMetrics,
    name=BytesInPerSec
    Count 每秒输入的流量
    kafka.server:type=BrokerTopicMetrics,
    name=BytesOutPerSec
    Count 每秒输出的流量
    kafka.server:type=BrokerTopicMetrics,
    name=BytesRejectedPerSec
    Count 每秒扔掉的流量
    kafka.server:type=BrokerTopicMetrics,
    name=MessagesInPerSec
    Count 每秒的消息写入总量
    kafka.server:type=BrokerTopicMetrics,
    name=FailedFetchRequestsPerSec
    Count 当前机器每秒fetch请求失败的数量
    kafka.server:type=BrokerTopicMetrics,
    name=FailedProduceRequestsPerSec
    Count 当前机器每秒produce请求失败的数量
    kafka.server:type=ReplicaManager,
    name=PartitionCount
    Value 该broker上的partition的数量
    kafka.server:type=ReplicaManager,
    name=LeaderCount
    Value Leader的replica的数量
    kafka.network:type=RequestMetrics,
    name=TotalTimeMs,request=FetchConsumer
    Count 一个请求FetchConsumer耗费的所有时间
    kafka.network:type=RequestMetrics,
    name=TotalTimeMs,request=FetchFollower
    Count 一个请求FetchFollower耗费的所有时间
    kafka.network:type=RequestMetrics,
    name=TotalTimeMs,request=Produce
    Count 一个请求Produce耗费的所有时间

    producer以及topic指标

    objectName 指标项 官网说明 译文说明
    kafka.producer:type=producer-metrics,client-id=console-producer(client-id会变化) incoming-byte-rate The average number of incoming bytes received per second from all servers. producer每秒的平均写入流量
    kafka.producer:type=producer-metrics,client-id=console-producer(client-id会变化) outgoing-byte-rate The average number of outgoing bytes sent per second to all servers. producer每秒的输出流量
    kafka.producer:type=producer-metrics,client-id=console-producer(client-id会变化) request-rate The average number of requests sent per second to the broker. producer每秒发给broker的平均request次数
    kafka.producer:type=producer-metrics,client-id=console-producer(client-id会变化) response-rate The average number of responses received per second from the broker. producer每秒发给broker的平均response次数
    kafka.producer:type=producer-metrics,client-id=console-producer(client-id会变化) request-latency-avg The average time taken for a fetch request. 一个fetch请求的平均时间
    kafka.producer:type=producer-topic-metrics,client-id=console-producer,topic=testjmx(client-id和topic名称会变化) record-send-rate The average number of records sent per second for a topic. 每秒从topic发送的平均记录数
    kafka.producer:type=producer-topic-metrics,client-id=console-producer,topic=testjmx(client-id和topic名称会变化) record-retry-total The total number of retried record sends 重试发送的消息总数量
    kafka.producer:type=producer-topic-metrics,client-id=console-producer,topic=testjmx(client-id和topic名称会变化) record-error-total The total number of record sends that resulted in errors 发送错误的消息总数量

    consumer指标

    objectName 指标项 官网说明 说明
    kafka.consumer:type=consumer-fetch-manager-metrics,client-id=consumer-1(client-id会变化) records-lag-max Number of messages the consumer lags behind the producer by. Published by the consumer, not broker. 由consumer提交的消息消费lag
    kafka.consumer:type=consumer-fetch-manager-metrics,client-id=consumer-1(client-id会变化) records-consumed-rate The average number of records consumed per second 每秒平均消费的消息数量
  • 相关阅读:
    maxContainerCapability 设置不足
    parquet code demo
    Windows下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
    jvm 调优 工具
    hive premanent udf 发布...
    centos6.5 升级python 到 python 2.7.11 安装 pip
    mapreduce 关于小文件导致任务缓慢的问题
    数据可视化开源系统(python开发)
    vs 中 vim vax 快捷键
    ViEmu for VS2013-3.2.1 破解(转)
  • 原文地址:https://www.cnblogs.com/fengzzi/p/10033800.html
Copyright © 2020-2023  润新知