如何在没有 ZooKeeper 的情况下获取 JMX 端口(仅限引导程序服务器)?
How to get JMX port without ZooKeeper (with bootstraper servers only)?
我们可以使用zk节点/brokers/ids/xxx
得到jmx_port
。现在 Kafka 正在转向无 ZooKeeper 的架构,我们如何仅使用 bootstrap 个服务器来获取此信息?有可能吗?
Kafka 是一个 Java 进程,所以是的,这是可能的。
代理启动时使用了一个环境变量 JMX_PORT
,您可以要求服务器管理员 set/document - https://github.com/apache/kafka/blob/3.2/bin/kafka-run-class.sh#L213
我目前仅将其用于 kafka broker,用于 prometheus。添加此行 Environment="KAFKA_OPTS=-javaagent:/kafka/jmx_prometheus_javaagent-0.3.1.jar=7080:/kafka/kafka-0-8-2.yml"
到 systemd 服务文件。当然需要下载jmx_prometheus_javaagent-0.3.1.jar.
yaml 文件如下所示:
lowercaseOutputName: true
rules:
- pattern : kafka.cluster<type=(.+), name=(.+), topic=(.+), partition=(.+)><>Value
name: kafka_cluster__
labels:
topic: ""
partition: ""
- pattern : kafka.log<type=Log, name=(.+), topic=(.+), partition=(.+)><>Value
name: kafka_log_
labels:
topic: ""
partition: ""
- pattern : kafka.controller<type=(.+), name=(.+)><>(Count|Value)
name: kafka_controller__
- pattern : kafka.network<type=(.+), name=(.+)><>Value
name: kafka_network__
- pattern : kafka.network<type=(.+), name=(.+)PerSec, request=(.+)><>Count
name: kafka_network___total
labels:
request: ""
- pattern : kafka.network<type=(.+), name=(\w+), networkProcessor=(.+)><>Count
name: kafka_network__
labels:
request: ""
type: COUNTER
- pattern : kafka.network<type=(.+), name=(\w+), request=(\w+)><>Count
name: kafka_network__
labels:
request: ""
- pattern : kafka.network<type=(.+), name=(\w+)><>Count
name: kafka_network__
- pattern : kafka.server<type=(.+), name=(.+)PerSec\w*, topic=(.+)><>Count
name: kafka_server___total
labels:
topic: ""
- pattern : kafka.server<type=(.+), name=(.+)PerSec\w*><>Count
name: kafka_server___total
type: COUNTER
- pattern : kafka.server<type=(.+), name=(.+), clientId=(.+), topic=(.+), partition=(.*)><>(Count|Value)
name: kafka_server__
labels:
clientId: ""
topic: ""
partition: ""
- pattern : kafka.server<type=(.+), name=(.+), topic=(.+), partition=(.*)><>(Count|Value)
name: kafka_server__
labels:
topic: ""
partition: ""
- pattern : kafka.server<type=(.+), name=(.+), topic=(.+)><>(Count|Value)
name: kafka_server__
labels:
topic: ""
type: COUNTER
- pattern : kafka.server<type=(.+), name=(.+), clientId=(.+), brokerHost=(.+), brokerPort=(.+)><>(Count|Value)
name: kafka_server__
labels:
clientId: ""
broker: ":"
- pattern : kafka.server<type=(.+), name=(.+), clientId=(.+)><>(Count|Value)
name: kafka_server__
labels:
clientId: ""
- pattern : kafka.server<type=(.+), name=(.+)><>(Count|Value)
name: kafka_server__
- pattern : kafka.(\w+)<type=(.+), name=(.+)PerSec\w*><>Count
name: kafka____total
- pattern : kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, topic=(.+)><>Count
name: kafka____total
labels:
topic: ""
type: COUNTER
- pattern : kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, topic=(.+), partition=(.+)><>Count
name: kafka____total
labels:
topic: ""
partition: ""
type: COUNTER
- pattern : kafka.(\w+)<type=(.+), name=(.+)><>(Count|Value)
name: kafka____
type: COUNTER
- pattern : kafka.(\w+)<type=(.+), name=(.+), (\w+)=(.+)><>(Count|Value)
name: kafka____
labels:
"": ""
我们可以使用zk节点/brokers/ids/xxx
得到jmx_port
。现在 Kafka 正在转向无 ZooKeeper 的架构,我们如何仅使用 bootstrap 个服务器来获取此信息?有可能吗?
Kafka 是一个 Java 进程,所以是的,这是可能的。
代理启动时使用了一个环境变量 JMX_PORT
,您可以要求服务器管理员 set/document - https://github.com/apache/kafka/blob/3.2/bin/kafka-run-class.sh#L213
我目前仅将其用于 kafka broker,用于 prometheus。添加此行 Environment="KAFKA_OPTS=-javaagent:/kafka/jmx_prometheus_javaagent-0.3.1.jar=7080:/kafka/kafka-0-8-2.yml"
到 systemd 服务文件。当然需要下载jmx_prometheus_javaagent-0.3.1.jar.
yaml 文件如下所示:
lowercaseOutputName: true
rules:
- pattern : kafka.cluster<type=(.+), name=(.+), topic=(.+), partition=(.+)><>Value
name: kafka_cluster__
labels:
topic: ""
partition: ""
- pattern : kafka.log<type=Log, name=(.+), topic=(.+), partition=(.+)><>Value
name: kafka_log_
labels:
topic: ""
partition: ""
- pattern : kafka.controller<type=(.+), name=(.+)><>(Count|Value)
name: kafka_controller__
- pattern : kafka.network<type=(.+), name=(.+)><>Value
name: kafka_network__
- pattern : kafka.network<type=(.+), name=(.+)PerSec, request=(.+)><>Count
name: kafka_network___total
labels:
request: ""
- pattern : kafka.network<type=(.+), name=(\w+), networkProcessor=(.+)><>Count
name: kafka_network__
labels:
request: ""
type: COUNTER
- pattern : kafka.network<type=(.+), name=(\w+), request=(\w+)><>Count
name: kafka_network__
labels:
request: ""
- pattern : kafka.network<type=(.+), name=(\w+)><>Count
name: kafka_network__
- pattern : kafka.server<type=(.+), name=(.+)PerSec\w*, topic=(.+)><>Count
name: kafka_server___total
labels:
topic: ""
- pattern : kafka.server<type=(.+), name=(.+)PerSec\w*><>Count
name: kafka_server___total
type: COUNTER
- pattern : kafka.server<type=(.+), name=(.+), clientId=(.+), topic=(.+), partition=(.*)><>(Count|Value)
name: kafka_server__
labels:
clientId: ""
topic: ""
partition: ""
- pattern : kafka.server<type=(.+), name=(.+), topic=(.+), partition=(.*)><>(Count|Value)
name: kafka_server__
labels:
topic: ""
partition: ""
- pattern : kafka.server<type=(.+), name=(.+), topic=(.+)><>(Count|Value)
name: kafka_server__
labels:
topic: ""
type: COUNTER
- pattern : kafka.server<type=(.+), name=(.+), clientId=(.+), brokerHost=(.+), brokerPort=(.+)><>(Count|Value)
name: kafka_server__
labels:
clientId: ""
broker: ":"
- pattern : kafka.server<type=(.+), name=(.+), clientId=(.+)><>(Count|Value)
name: kafka_server__
labels:
clientId: ""
- pattern : kafka.server<type=(.+), name=(.+)><>(Count|Value)
name: kafka_server__
- pattern : kafka.(\w+)<type=(.+), name=(.+)PerSec\w*><>Count
name: kafka____total
- pattern : kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, topic=(.+)><>Count
name: kafka____total
labels:
topic: ""
type: COUNTER
- pattern : kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, topic=(.+), partition=(.+)><>Count
name: kafka____total
labels:
topic: ""
partition: ""
type: COUNTER
- pattern : kafka.(\w+)<type=(.+), name=(.+)><>(Count|Value)
name: kafka____
type: COUNTER
- pattern : kafka.(\w+)<type=(.+), name=(.+), (\w+)=(.+)><>(Count|Value)
name: kafka____
labels:
"": ""