Kafka 模块

编辑

这是 Kafka 模块。

默认的度量集为 consumergrouppartition

如果在 Kafka 集群中配置了授权,则 Metricbeat 用户需要以下 ACL:

  • READ 主题,用于要监控的主题
  • DESCRIBE 组,用于要监控的组

例如,如果 stats 用户用于 Metricbeat 来监控所有主题和所有消费者组,则可以使用以下命令授予 ACL:

kafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:stats --operation Read --topic '*'
kafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:stats --operation Describe --group '*'

兼容性

编辑

此模块已通过 Kafka 0.10.2.1、1.1.0、2.1.1 和 2.2.2 测试。

Broker、Producer、Consumer 度量集需要 Jolokia 来获取 JMX 指标。请参阅链接以了解 Jolokia 的兼容性说明。

用法

编辑

Broker、Producer、Consumer 度量集需要 Jolokia 来获取 JMX 指标。请参阅这些度量集的文档,了解如何使用 Jolokia。

仪表盘

编辑

Kafka 模块附带一个预定义的仪表盘。例如

metricbeat kafka dashboard

示例配置

Kafka 模块支持在 模块 中描述的标准配置选项。这是一个示例配置

metricbeat.modules:
# Kafka metrics collected using the Kafka protocol
- module: kafka
  #metricsets:
  #  - partition
  #  - consumergroup
  period: 10s
  hosts: ["localhost:9092"]

  #client_id: metricbeat
  #retries: 3
  #backoff: 250ms

  # List of Topics to query metadata for. If empty, all topics will be queried.
  #topics: []

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

  # Client Certificate Passphrase (in case your Client Certificate Key is encrypted)
  #ssl.key_passphrase: "yourKeyPassphrase"

  # SASL authentication
  #username: ""
  #password: ""

  # SASL authentication mechanism used. Can be one of PLAIN, SCRAM-SHA-256 or SCRAM-SHA-512.
  # Defaults to PLAIN when `username` and `password` are configured.
  #sasl.mechanism: ''

# Metrics collected from a Kafka broker using Jolokia
#- module: kafka
#  metricsets:
#    - broker
#  period: 10s
#  hosts: ["localhost:8779"]

# Metrics collected from a Java Kafka consumer using Jolokia
#- module: kafka
#  metricsets:
#    - consumer
#  period: 10s
#  hosts: ["localhost:8774"]

# Metrics collected from a Java Kafka producer using Jolokia
#- module: kafka
#  metricsets:
#    - producer
#  period: 10s
#  hosts: ["localhost:8775"]

度量集

提供以下度量集: