General availability (GA) Open source Grafana Cloud
Last reviewed: October 6, 2026

prometheus.exporter.kafka

The prometheus.exporter.kafka component embeds the kafka_exporter to collect metrics from a Kafka server.

You can specify multiple prometheus.exporter.kafka components by giving them different labels.

Usage

Alloy
prometheus.exporter.kafka "<LABEL>" {
  kafka_uris = ["<KAFKA_URI>"]
}

Arguments

You can use the following arguments with prometheus.exporter.kafka:

NameTypeDescriptionDefaultRequired
kafka_urislist(string)Addresses of the Kafka servers in host:port form.yes
allow_auto_topic_creationboolWhether the broker may auto-create requested topics that don’t exist.no
allow_concurrencyboolWhether each scrape triggers its own Kafka operations.trueno
ca_filestringCertificate authority file for TLS client authentication.no
cert_filestringCertificate file for TLS client authentication.no
groups_exclude_regexstringRegex that determines which consumer groups to exclude."^$"no
groups_filter_regexstringRegex filter for consumer groups to monitor.".*"no
gssapi_kerberos_auth_typestringKerberos authentication type. Either keytabAuth or userAuth.no
gssapi_kerberos_config_pathstringKerberos configuration path.no
gssapi_key_tab_pathstringKerberos keytab path.no
gssapi_realmstringKerberos realm.no
gssapi_service_namestringService name for Kerberos authentication.no
insecure_skip_verifyboolWhether to skip validation of the server’s certificate.no
instancestringThe instance label for the exported targets.no
kafka_cluster_namestringKafka cluster name.no
kafka_versionstringKafka broker version."2.0.0"no
key_filestringKey file for TLS client authentication.no
max_offsetsintMaximum number of offsets to store per partition in the interpolation table.1000no
metadata_refresh_intervaldurationMetadata refresh interval."1m"no
offset_show_allboolWhether to show the offset and lag for all consumer groups, not just connected ones.trueno
prune_interval_secondsintDeprecated. Has no effect. Use metadata_refresh_interval instead.30no
sasl_disable_pafx_fastboolWhether to disable PA_FX_FAST in the Kerberos client.no
sasl_mechanismstringSASL mechanism. One of plain, scram-sha256, scram-sha512, or gssapi.no
sasl_passwordsecretSASL user password.no
sasl_usernamestringSASL user name.no
tls_server_namestringServer name to verify against the returned certificates.no
topic_workersintNumber of concurrent workers that collect topic metrics.100no
topics_exclude_regexstringRegex that determines which topics to exclude."^$"no
topics_filter_regexstringRegex filter for topics to monitor.".*"no
use_saslboolWhether to connect using SASL.no
use_sasl_handshakeboolWhether to use the SASL handshake. Set to false only for a non-Kafka SASL proxy.trueno
use_tlsboolWhether to connect using TLS.no
use_zookeeper_lagboolWhether to read consumer group lag from Apache ZooKeeper.no
zookeeper_urislist(string)Addresses of the Apache ZooKeeper servers in host:port form.no

When allow_concurrency is true, every scrape triggers its own Kafka operations. When it’s false, concurrent scrapes share a single set of results.

Caution

Set allow_concurrency to false on large clusters. Leaving it enabled makes each concurrent scrape issue its own Kafka operations, which can place significant load on your brokers.

When insecure_skip_verify is true, the component doesn’t check the server’s certificate for validity. This makes your TLS connections insecure.

The component verifies the hostname on returned certificates unless you enable insecure_skip_verify. If you don’t set tls_server_name, the component uses the host from the corresponding kafka_uris entry.

When you enable use_sasl, you must also set sasl_username and sasl_password. When you enable use_zookeeper_lag, you must also set zookeeper_uris.

When kafka_uris contains one address, the component sets the instance label on its exported targets to that address. When kafka_uris contains more than one address, you must set instance, and the component uses that value as the label.

Blocks

The prometheus.exporter.kafka component doesn’t support any blocks. You can configure this component with arguments.

Exported fields

The following fields are exported and can be referenced by other components.

NameTypeDescription
targetslist(map(string))The targets that can be used to collect exporter metrics.

For example, the targets can either be passed to a discovery.relabel component to rewrite the targets’ label sets or to a prometheus.scrape component that collects the exposed metrics.

The exported targets use the configured in-memory traffic address specified by the run command.

Component health

prometheus.exporter.kafka is only reported as unhealthy if given an invalid configuration. In those cases, exported fields retain their last healthy values.

Debug information

prometheus.exporter.kafka doesn’t expose any component-specific debug information.

Debug metrics

prometheus.exporter.kafka doesn’t expose any component-specific debug metrics.

Example

This example uses a prometheus.scrape component to collect metrics from prometheus.exporter.kafka:

Alloy
prometheus.exporter.kafka "example" {
  kafka_uris = ["localhost:9092"]
}

// Configure a prometheus.scrape component to collect Kafka metrics.
prometheus.scrape "demo" {
  targets    = prometheus.exporter.kafka.example.targets
  forward_to = [prometheus.remote_write.demo.receiver]
}

prometheus.remote_write "demo" {
  endpoint {
    url = "<PROMETHEUS_REMOTE_WRITE_URL>"

    basic_auth {
      username = "<USERNAME>"
      password = "<PASSWORD>"
    }
  }
}

Replace the following:

  • <PROMETHEUS_REMOTE_WRITE_URL>: The URL of the Prometheus remote_write compatible server to send metrics to.
  • <USERNAME>: The username to use for authentication to the remote_write API.
  • <PASSWORD>: The password to use for authentication to the remote_write API.

Compatible components

prometheus.exporter.kafka has exports that can be consumed by the following components:

Note

Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. Refer to the linked documentation for more details.