Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana-cloud/send-data/alloy/reference/components/prometheus/prometheus.exporter.kafka.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana-cloud/send-data/alloy/reference/components/prometheus/prometheus.exporter.kafka/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
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
prometheus.exporter.kafka "<LABEL>" {
kafka_uris = ["<KAFKA_URI>"]
}Arguments
You can use the following arguments with prometheus.exporter.kafka:
| Name | Type | Description | Default | Required |
|---|---|---|---|---|
kafka_uris | list(string) | Addresses of the Kafka servers in host:port form. | yes | |
allow_auto_topic_creation | bool | Whether the broker may auto-create requested topics that don’t exist. | no | |
allow_concurrency | bool | Whether each scrape triggers its own Kafka operations. | true | no |
ca_file | string | Certificate authority file for TLS client authentication. | no | |
cert_file | string | Certificate file for TLS client authentication. | no | |
groups_exclude_regex | string | Regex that determines which consumer groups to exclude. | "^$" | no |
groups_filter_regex | string | Regex filter for consumer groups to monitor. | ".*" | no |
gssapi_kerberos_auth_type | string | Kerberos authentication type. Either keytabAuth or userAuth. | no | |
gssapi_kerberos_config_path | string | Kerberos configuration path. | no | |
gssapi_key_tab_path | string | Kerberos keytab path. | no | |
gssapi_realm | string | Kerberos realm. | no | |
gssapi_service_name | string | Service name for Kerberos authentication. | no | |
insecure_skip_verify | bool | Whether to skip validation of the server’s certificate. | no | |
instance | string | The instance label for the exported targets. | no | |
kafka_cluster_name | string | Kafka cluster name. | no | |
kafka_version | string | Kafka broker version. | "2.0.0" | no |
key_file | string | Key file for TLS client authentication. | no | |
max_offsets | int | Maximum number of offsets to store per partition in the interpolation table. | 1000 | no |
metadata_refresh_interval | duration | Metadata refresh interval. | "1m" | no |
offset_show_all | bool | Whether to show the offset and lag for all consumer groups, not just connected ones. | true | no |
prune_interval_seconds | int | Deprecated. Has no effect. Use metadata_refresh_interval instead. | 30 | no |
sasl_disable_pafx_fast | bool | Whether to disable PA_FX_FAST in the Kerberos client. | no | |
sasl_mechanism | string | SASL mechanism. One of plain, scram-sha256, scram-sha512, or gssapi. | no | |
sasl_password | secret | SASL user password. | no | |
sasl_username | string | SASL user name. | no | |
tls_server_name | string | Server name to verify against the returned certificates. | no | |
topic_workers | int | Number of concurrent workers that collect topic metrics. | 100 | no |
topics_exclude_regex | string | Regex that determines which topics to exclude. | "^$" | no |
topics_filter_regex | string | Regex filter for topics to monitor. | ".*" | no |
use_sasl | bool | Whether to connect using SASL. | no | |
use_sasl_handshake | bool | Whether to use the SASL handshake. Set to false only for a non-Kafka SASL proxy. | true | no |
use_tls | bool | Whether to connect using TLS. | no | |
use_zookeeper_lag | bool | Whether to read consumer group lag from Apache ZooKeeper. | no | |
zookeeper_uris | list(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_concurrencytofalseon 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.
| Name | Type | Description |
|---|---|---|
targets | list(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:
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 Prometheusremote_writecompatible server to send metrics to.<USERNAME>: The username to use for authentication to theremote_writeAPI.<PASSWORD>: The password to use for authentication to theremote_writeAPI.
Compatible components
prometheus.exporter.kafka has exports that can be consumed by the following components:
- Components that consume Targets
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.
Was this page helpful?
Related resources from Grafana Labs


