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.10.1.0 (and later).
Binary can be downloaded from Releases page.
make
make docker
docker pull dparrott/kafka-exporter:latest
It can be used directly instead of having to build the image yourself Docker Hub dparrott/kafka-exporter
kafka_exporter --kafka.server=kafka:9092 [--kafka.server=another-server ...]
docker run -ti --rm -p 9308:9308 dparrott/kafka-exporter --kafka.server=kafka:9092 [--kafka.server=another-server ...]
This image is configurable using different flags
Flag name | Default | Description |
---|---|---|
kafka.server | kafka:9092 | Addresses (host:port) of Kafka server |
kafka.version | 1.0.0 | Kafka broker version |
sasl.enabled | false | Connect using SASL/PLAIN |
sasl.handshake | true | Only set this to false if using a non-Kafka SASL proxy |
sasl.username | SASL user name | |
sasl.password | SASL user password | |
sasl.mechanism | SASL mechanism can be plain, scram-sha512, scram-sha256 | |
tls.enabled | false | Connect using TLS |
tls.ca-file | The optional certificate authority file for TLS client authentication | |
tls.cert-file | The optional certificate file for client authentication | |
tls.key-file | The optional key file for client authentication | |
tls.insecure-skip-tls-verify | false | If true, the server's certificate will not be checked for validity |
topic.filter | .* | Regex that determines which topics to collect |
group.filter | .* | Regex that determines which consumer groups to collect |
web.listen-address | :9308 | Address to listen on for web interface and telemetry |
web.telemetry-path | /metrics | Path under which to expose metrics |
log.level | info | Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] |
log.enable-sarama | false | Turn on Sarama logging |
max.offsets | 1000 | Maximum number of offsets to store in the interpolation table for a partition |
prune.interval | 30 | How frequently should the interpolation table be pruned, in seconds |
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 information |
---|---|
kafka_brokers |
Number of Brokers in the Kafka Cluster |
Metrics output example
# HELP kafka_brokers Number of Brokers in the Kafka Cluster.
# TYPE kafka_brokers gauge
kafka_brokers 3
Metrics details
Name | Exposed information |
---|---|
kafka_topic_partitions |
Number of partitions for this Topic |
kafka_topic_partition_current_offset |
Current Offset of a Broker at Topic/Partition |
kafka_topic_partition_oldest_offset |
Oldest Offset of a Broker at Topic/Partition |
kafka_topic_partition_in_sync_replica |
Number of In-Sync Replicas for this Topic/Partition |
kafka_topic_partition_leader |
Leader Broker ID of this Topic/Partition |
kafka_topic_partition_leader_is_preferred |
1 if Topic/Partition is using the Preferred Broker |
kafka_topic_partition_replicas |
Number of Replicas for this Topic/Partition |
kafka_topic_partition_under_replicated_partition |
1 if Topic/Partition is under Replicated |
Metrics output example
# HELP kafka_topic_partitions Number of partitions for this Topic
# TYPE kafka_topic_partitions gauge
kafka_topic_partitions{topic="__consumer_offsets"} 50
# HELP kafka_topic_partition_current_offset Current Offset of a Broker at Topic/Partition
# TYPE kafka_topic_partition_current_offset gauge
kafka_topic_partition_current_offset{partition="0",topic="__consumer_offsets"} 0
# HELP kafka_topic_partition_oldest_offset Oldest Offset of a Broker at Topic/Partition
# TYPE kafka_topic_partition_oldest_offset gauge
kafka_topic_partition_oldest_offset{partition="0",topic="__consumer_offsets"} 0
# HELP kafka_topic_partition_in_sync_replica Number of In-Sync Replicas for this Topic/Partition
# TYPE kafka_topic_partition_in_sync_replica gauge
kafka_topic_partition_in_sync_replica{partition="0",topic="__consumer_offsets"} 3
# HELP kafka_topic_partition_leader Leader Broker ID of this Topic/Partition
# TYPE kafka_topic_partition_leader gauge
kafka_topic_partition_leader{partition="0",topic="__consumer_offsets"} 0
# HELP kafka_topic_partition_leader_is_preferred 1 if Topic/Partition is using the Preferred Broker
# TYPE kafka_topic_partition_leader_is_preferred gauge
kafka_topic_partition_leader_is_preferred{partition="0",topic="__consumer_offsets"} 1
# HELP kafka_topic_partition_replicas Number of Replicas for this Topic/Partition
# TYPE kafka_topic_partition_replicas gauge
kafka_topic_partition_replicas{partition="0",topic="__consumer_offsets"} 3
# HELP kafka_topic_partition_under_replicated_partition 1 if Topic/Partition is under Replicated
# TYPE kafka_topic_partition_under_replicated_partition gauge
kafka_topic_partition_under_replicated_partition{partition="0",topic="__consumer_offsets"} 0
Metrics details
Name | Exposed information |
---|---|
kafka_consumergroup_current_offset |
Current Offset of a ConsumerGroup at Topic/Partition |
kafka_consumergroup_lag |
Current Approximate Lag of a ConsumerGroup at Topic/Partition |
Metrics output example
# HELP kafka_consumergroup_current_offset Current Offset of a ConsumerGroup at Topic/Partition
# TYPE kafka_consumergroup_current_offset gauge
kafka_consumergroup_current_offset{consumergroup="KMOffsetCache-kafka-manager-3806276532-ml44w",partition="0",topic="__consumer_offsets"} -1
# HELP kafka_consumergroup_lag Current Approximate Lag of a ConsumerGroup at Topic/Partition
# TYPE kafka_consumergroup_lag gauge
kafka_consumergroup_lag{consumergroup="KMOffsetCache-kafka-manager-3806276532-ml44w",partition="0",topic="__consumer_offsets"} 1
Metric Details
Name | Exposed information |
---|---|
kafka_consumer_lag_millis |
Current approximation of consumer lag for a ConsumerGroup at Topic/Partition |
kafka_consumer_lag_extrapolation |
Indicates that a consumer group lag estimation used extrapolation |
kafka_consumer_lag_interpolation |
Indicates that a consumer group lag estimation used interpolation |
Metrics output example
# HELP kafka_consumer_lag_extrapolation Indicates that a consumer group lag estimation used extrapolation
# TYPE kafka_consumer_lag_extrapolation counter
kafka_consumer_lag_extrapolation{consumergroup="perf-consumer-74084",partition="0",topic="test"} 1
# HELP kafka_consumer_lag_interpolation Indicates that a consumer group lag estimation used interpolation
# TYPE kafka_consumer_lag_interpolation counter
kafka_consumer_lag_interpolation{consumergroup="perf-consumer-74084",partition="0",topic="test"} 1
# HELP kafka_consumer_lag_millis Current approximation of consumer lag for a ConsumerGroup at Topic/Partition
# TYPE kafka_consumer_lag_millis gauge
kafka_consumer_lag_millis{consumergroup="perf-consumer-74084",partition="0",topic="test"} 3.4457231197552e+10
Grafana Dashboard ID: 7589, name: Kafka Exporter Overview.
For details of the dashboard please see Kafka Exporter Overview.
The technique to estimate lag for a consumer group, topic, and partition is taken from the Lightbend Kafka Lag Exporter.
Once the exporter starts up, sampling of the next offset to be produced begins. The interpolation table is built from these samples, and the current offset for each monitored consumer group are compared against values in the table. If an upper and lower bound for the current offset of a consumer group are in the table, the interpolation technique is used. If only an upper bound is container within the table, extrapolation is used.
At a configurable interval prune.interval
(default is 30 seconds) an operation to prune the interpolation table is performed. Any consumer group or topic that are no longer listed by the broker is removed. The number of offsets for each partition is trimmed down to max.offsets
(default 1000), with the oldest offsets removed first.
Pruning of the interpolation table happens on a separate thread and thread safety is ensured by a lock around the interpolation table.
To contribute to the upstream project, please open a pull request.
To contribute to this fork please open a pull request here
To donate to the developer of the project this is forked from please use the donation link below
Code is licensed under the Apache License 2.0.