Kafka Exporter for Prometheus

Published
Length
3 min read

Luis Felipe Dias

All posts

To run a kafka exporter for prometheus, deploy the collector and point it to your brokers. The tool reads cluster metadata and exposes metrics on an HTTP port for scraping. Teams often deploy this collector in a shared cluster with broad read permissions. When permissions are too wide, any user or app can read sensitive topic metadata. Overly broad roles also make it hard to track who runs admin tasks when alerts fire. How a kafka exporter for prometheus works A kafka exporter for prometheus

Prometheus Security: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

To run a kafka exporter for prometheus, deploy the collector and point it to your brokers. The tool reads cluster metadata and exposes metrics on an HTTP port for scraping. Teams often deploy this collector in a shared cluster with broad read permissions. When permissions are too wide, any user or app can read sensitive topic metadata. Overly broad roles also make it hard to track who runs admin tasks when alerts fire.

How a kafka exporter for prometheus works

A kafka exporter for prometheus acts as a bridge between your message brokers and your metrics server. Kafka stores data about topics, partitions, and consumer groups inside the cluster. Prometheus cannot read the native Kafka protocol on its own. The exporter logs in to the brokers as a standard client. It asks the cluster for current offset numbers and partition states. Then it translates those numbers into plain text metrics that Prometheus can scrape on a timer.

This architecture differs from JMX collection. JMX agents run inside each broker process and report low-level memory, CPU, and disk metrics. The standalone exporter runs outside the brokers as a separate app. You only need one instance of the exporter per cluster. It focuses on cluster-wide metrics like consumer group lag and topic message counts. Teams often use both tools together to see both host health and consumer progress.

Setting up exporter permissions and network rules

To set up the exporter, you first give it a network route to your brokers. Next, you create a dedicated client identity on the Kafka cluster. You should set up TLS encryption so traffic between the exporter and brokers stays private. You also need to configure SASL credentials so the cluster knows which app is logging in.

After you set up the identity, you assign access control lists to that role. The exporter needs permission to describe topics, consumer groups, and cluster nodes. It does not need permission to read actual message payloads or write new events. Keeping these rules tight prevents the collector from changing topic data by mistake. Once the exporter is running, you point your Prometheus server to the collector port.

Prometheus Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native metrics solve and where gaps remain

This metric setup solves the problem of silent consumer delays. When a consumer group falls behind, the exporter spots the growing offset gap right away. Alert rules can then notify the on-call team to check the slow service. The setup also shows if a partition loses its leader or if a broker drops offline.

Still, metric collection only tells you that a problem exists. When an alert fires, an engineer still has to log in to fix the cluster. Native Kafka roles decide who can log in, not what commands they run in flight. Teams often share admin keys or use broad roles during an outage. If an engineer inspects messages to debug lag, raw data like emails or card numbers appears. Data masking is needed to rewrite matched fields in results during live debugging. Without command-level checks, a single mistyped admin command can delete a production topic.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

What is the difference between JMX exporter and Kafka exporter?

JMX exporter runs inside each broker to track Java memory, CPU, and disk health. Kafka exporter runs as a separate app and tracks cluster-wide consumer lag and offsets.

Does the exporter need permission to read message payloads?

No, the collector only reads metadata about topics, partitions, and consumer group offsets. You should block topic payload read access in your cluster access control lists.

How many exporter instances should I run per cluster?

You only need one active instance per cluster because it queries metadata from all brokers. Running multiple active instances against the same cluster creates duplicate metrics and wastes broker resources.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.