Grafana/prometheus 中没有 kafka 指标

No kafka metrics in Grafana/prometheus

我成功部署了 helm chart prometheus operator, kube-prometheus and kafka(尝试了图像 danielqsj/kafka_exporter v1.0.1v1.2.0)。

大多数情况下使用默认值安装,rbac 已启用。

我可以在 prometheus 的 Kafka 目标列表中看到 3 up 个节点,但是当进入 Grafana 时,我可以看到任何带有 kafka overview

的 kafka 指标

我遗漏了什么或者我可以检查什么来解决这个问题?

我可以看到指标以 java_kafka_ 开头,但没有 jvm_,只有少数 jmx_ 个指标。

我发现有人报告了类似的问题 (https://groups.google.com/forum/#!searchin/prometheus-users/jvm_%7Csort:date/prometheus-users/OtYM7qGMbvA/dZ4vIfWLAgAJ),所以我使用旧版本的 jmx exporter 从 0.6 部署到 0.9,仍然没有 jvm_ 指标。

有什么我遗漏的吗?

环境:

kuberentes:AWS EKS(kubernetes版本为1.10.x)

public grafana 仪表板:kafka overview

您必须为提供 --set prometheus.jmx.enabled=true,prometheus.kafka.enabled=true 的 kafka helm 图表打开 jmx 和导出器。默认值为 false

刚刚意识到 README 中提到的 jmx-exporter 的所有者:

This exporter is intended to be run as a Java Agent, exposing a HTTP server and serving metrics of the local JVM. It can be also run as an independent HTTP server and scrape remote JMX targets, but this has various disadvantages, such as being harder to configure and being unable to expose process metrics (e.g., memory and CPU usage). Running the exporter as a Java Agent is thus strongly encouraged.

直到我看到这个评论:

才真正明白那是什么意思

https://github.com/prometheus/jmx_exporter/issues/111#issuecomment-341983150

@brian-brazil can you add some sort of tip to the readme that jvm_* metrics are only exposed when using the Java agent? It took me an hour or two of troubleshooting and searching old issues to figure this out, after playing only with the HTTP server version. Thanks!

因此 jmx-exporter 必须 运行 和 java agent 才能获得 jvm_ 指标。 jmx_prometheus_httpserver不支持,但这是kafka helm chart中的默认设置。

https://github.com/kubernetes/charts/blob/master/incubator/kafka/templates/statefulset.yaml#L82

command:
- sh
- -exc
- |
  trap "exit 0" TERM; \
  while :; do \
  java \
  -XX:+UnlockExperimentalVMOptions \
  -XX:+UseCGroupMemoryLimitForHeap \
  -XX:MaxRAMFraction=1 \
  -XshowSettings:vm \
  -jar \
  jmx_prometheus_httpserver.jar \              # <<< here
  {{ .Values.prometheus.jmx.port | quote }} \
  /etc/jmx-kafka/jmx-kafka-prometheus.yml & \
  wait $! || sleep 3; \
  done