This is documentation for the next version of Grafana Alloy Documentation. For the latest stable release, go to the latest version.
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:
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.
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.


