Kafka exporter for Prometheus. For other metrics from Kafka, have a look at the JMX exporter.
- Compatibility
- Dependency
- Download
- Compile
- Run
- Flags
- Metrics
- Grafana Dashboard
- Contribute
- Donation
- License
Support Apache Kafka version 0.11.0.0 (and later).
Binary can be downloaded from Releases page.
make
make docker
docker pull danielqsj/kafka-exporter:latest
It can be used directly instead of having to build the image yourself. (Docker Hub danielqsj/kafka-exporter)
kafka_exporter --kafka.server=kafka:9092 [--kafka.server=another-server ...]
docker run -ti --rm -p 9308:9308 danielqsj/kafka-exporter --kafka.server=kafka:9092 [--kafka.server=another-server ...]
This image is configurable using different flags
Flag name | Env var name | Default | Description |
---|---|---|---|
kafka.server | KAFKA_SERVER | kafka:9092 | Addresses (host:port) of Kafka server |
kafka.version | KAFKA_VERSION | 1.0.0 | Kafka broker version |
sasl.enabled | SASL_ENABLED | false | Connect using SASL/PLAIN |
sasl.handshake | SASL_HANDSHAKE | true | Only set this to false if using a non-Kafka SASL proxy |
sasl.username | SASL_USERNAME | SASL user name | |
sasl.password | SASL_PASSWORD | SASL user password | |
sasl.mechanism | SASL_MECHANISM | SASL mechanism, valid values: [SCRAM-SHA-256, SCRAM-SHA-512] | |
tls.enabled | TLS_ENABLED | false | Connect using TLS |
tls.ca-file | TLS_CA_FILE | The optional certificate authority file for TLS client authentication | |
tls.cert-file | TLS_CERT_FILE | The optional certificate file for client authentication | |
tls.key-file | TLS_KEY_FILE | The optional key file for client authentication | |
tls.insecure-skip-tls-verify | TLS_INSECURE_SKIP_TLS_VERIFY | false | If true, the server's certificate will not be checked for validity |
topic.filter | TOPIC_FILTER | .* | Regex that determines which topics to collect |
topic.exclude | TOPIC_EXCLUDE | Regex that determines which topics to exclude | |
group.filter | GROUP_FILTER | .* | Regex that determines which consumer groups to collect |
group.exclude | GROUP_EXCLUDE | Regex that determines which consumer groups to exclude | |
web.listen-address | WEB_LISTEN_ADDRESS | :9308 | Address to listen on for web interface and telemetry |
web.telemetry-path | WEB_TELEMETRY_PATH | /metrics | Path under which to expose metrics |
log.level | LOG_LEVEL | info | Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] |
log.enable-sarama | LOG_ENABLE_SARAMA | false | Turn on Sarama logging |
use.consumelag.zookeeper | USE_CONSUMELAG_ZOOKEEPER | false | You need to use a group from zookeeper |
zookeeper.server | ZOOKEEPER_SERVER | localhost:2181 | Zookeeper server |
kafka.labels | KAFKA_LABELS | Kafka server name | |
refresh.metadata | REFRESH_METADATA | 30s | Metadata refresh interval |
enabled.metric | ENABLED_METRIC | Export only some metrics, valid values: [brokers, partitions, partition_current_offset, partition_oldest_offset, partition_leader, partition_replicas, partition_in_sync_replica, partition_leader_is_preferred, partition_under_replicated_partition, current_offset, current_offset_sum, lag, lag_seconds, lag_zookeeper, lag_sum, members] |
Boolean values are uniquely managed by Kingpin. Each boolean flag will have a negative complement:
--<name>
and --no-<name>
.
For example:
If you need to disable sasl.handshake
, you could add flag --no-sasl.handshake
Documents about exposed Prometheus metrics.
For details on the underlying metrics please see Apache Kafka.
Metrics details
Name | Exposed informations |
---|---|
kafka_exporter_brokers |
Number of Brokers in the Kafka Cluster |
Metrics output example
# HELP kafka_exporter_brokers Number of Brokers in the Kafka Cluster.
# TYPE kafka_exporter_brokers gauge
kafka_exporter_brokers 3
Metrics details
Name | Exposed informations |
---|---|
kafka_exporter_topic_partitions |
Number of partitions for this Topic |
kafka_exporter_topic_partition_current_offset |
Current Offset of a Broker at Topic/Partition |
kafka_exporter_topic_partition_oldest_offset |
Oldest Offset of a Broker at Topic/Partition |
kafka_exporter_topic_partition_in_sync_replica |
Number of In-Sync Replicas for this Topic/Partition |
kafka_exporter_topic_partition_leader |
Leader Broker ID of this Topic/Partition |
kafka_exporter_topic_partition_leader_is_preferred |
1 if Topic/Partition is using the Preferred Broker |
kafka_exporter_topic_partition_replicas |
Number of Replicas for this Topic/Partition |
kafka_exporter_topic_partition_under_replicated_partition |
1 if Topic/Partition is under Replicated |
Metrics output example
# HELP kafka_exporter_topic_partitions Number of partitions for this Topic
# TYPE kafka_exporter_topic_partitions gauge
kafka_exporter_topic_partitions{topic="__consumer_offsets"} 50
# HELP kafka_exporter_topic_partition_current_offset Current Offset of a Broker at Topic/Partition
# TYPE kafka_exporter_topic_partition_current_offset gauge
kafka_topic_partition_current_offset{partition="0",topic="__consumer_offsets"} 0
# HELP kafka_exporter_topic_partition_oldest_offset Oldest Offset of a Broker at Topic/Partition
# TYPE kafka_exporter_topic_partition_oldest_offset gauge
kafka_exporter_topic_partition_oldest_offset{partition="0",topic="__consumer_offsets"} 0
# HELP kafka_exporter_topic_partition_in_sync_replica Number of In-Sync Replicas for this Topic/Partition
# TYPE kafka_exporter_topic_partition_in_sync_replica gauge
kafka_exporter_topic_partition_in_sync_replica{partition="0",topic="__consumer_offsets"} 3
# HELP kafka_exporter_topic_partition_leader Leader Broker ID of this Topic/Partition
# TYPE kafka_exporter_topic_partition_leader gauge
kafka_exporter_topic_partition_leader{partition="0",topic="__consumer_offsets"} 0
# HELP kafka_exporter_topic_partition_leader_is_preferred 1 if Topic/Partition is using the Preferred Broker
# TYPE kafka_exporter_topic_partition_leader_is_preferred gauge
kafka_exporter_topic_partition_leader_is_preferred{partition="0",topic="__consumer_offsets"} 1
# HELP kafka_exporter_topic_partition_replicas Number of Replicas for this Topic/Partition
# TYPE kafka_exporter_topic_partition_replicas gauge
kafka_exporter_topic_partition_replicas{partition="0",topic="__consumer_offsets"} 3
# HELP kafka_exporter_topic_partition_under_replicated_partition 1 if Topic/Partition is under Replicated
# TYPE kafka_exporter_topic_partition_under_replicated_partition gauge
kafka_exporter_topic_partition_under_replicated_partition{partition="0",topic="__consumer_offsets"} 0
Metrics details
Name | Exposed informations |
---|---|
kafka_exporter_consumergroup_current_offset |
Current Offset of a ConsumerGroup at Topic/Partition |
kafka_exporter_consumergroup_lag |
Current Approximate Lag of a ConsumerGroup at Topic/Partition |
kafka_exporter_consumergroup_lag_seconds |
Current Approximate Lag of a ConsumerGroup at Topic/Partition in seconds |
Metrics output example
# HELP kafka_exporter_consumergroup_current_offset Current Offset of a ConsumerGroup at Topic/Partition
# TYPE kafka_exporter_consumergroup_current_offset gauge
kafka_exporter_consumergroup_current_offset{consumergroup="KMOffsetCache-kafka-manager-3806276532-ml44w",partition="0",topic="__consumer_offsets"} -1
# HELP kafka_exporter_consumergroup_lag Current Approximate Lag of a ConsumerGroup at Topic/Partition
# TYPE kafka_exporter_consumergroup_lag gauge
kafka_exporter_consumergroup_lag{consumergroup="KMOffsetCache-kafka-manager-3806276532-ml44w",partition="0",topic="__consumer_offsets"} 1
If you like Kafka Exporter, please give me a star. This will help more people know Kafka Exporter.
Please feel free to send me pull requests.
Your donation will encourage me to continue to improve Kafka Exporter. Support Alipay donation.
link to https://github.com/danielqsj/kafka_exporter
Code is licensed under the Apache License 2.0.