Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new metric for kafka topic partition size. #298

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

xxm404
Copy link

@xxm404 xxm404 commented Jan 31, 2022

No description provided.

@xxm404
Copy link
Author

xxm404 commented Feb 7, 2022

New metric

kafka_topic_partition_size{partition="30",topic="__consumer_offsets"} 2443
kafka_topic_partition_size{partition="31",topic="__consumer_offsets"} 1031
kafka_topic_partition_size{partition="32",topic="__consumer_offsets"} 1738
kafka_topic_partition_size{partition="33",topic="__consumer_offsets"} 0
kafka_topic_partition_size{partition="34",topic="__consumer_offsets"} 0
kafka_topic_partition_size{partition="35",topic="__consumer_offsets"} 614
kafka_topic_partition_size{partition="36",topic="__consumer_offsets"} 578
kafka_topic_partition_size{partition="37",topic="__consumer_offsets"} 24920
kafka_topic_partition_size{partition="38",topic="__consumer_offsets"} 17611
kafka_topic_partition_size{partition="39",topic="__consumer_offsets"} 9930

@xxm404
Copy link
Author

xxm404 commented Feb 7, 2022

@danielqsj hi, I add a new metric for a topic partition size, like this

kafka_topic_partition_size{partition="30",topic="__consumer_offsets"} 2443
kafka_topic_partition_size{partition="31",topic="__consumer_offsets"} 1031
kafka_topic_partition_size{partition="32",topic="__consumer_offsets"} 1738
kafka_topic_partition_size{partition="33",topic="__consumer_offsets"} 0
kafka_topic_partition_size{partition="34",topic="__consumer_offsets"} 0
kafka_topic_partition_size{partition="35",topic="__consumer_offsets"} 614
kafka_topic_partition_size{partition="36",topic="__consumer_offsets"} 578
kafka_topic_partition_size{partition="37",topic="__consumer_offsets"} 24920
kafka_topic_partition_size{partition="38",topic="__consumer_offsets"} 17611
kafka_topic_partition_size{partition="39",topic="__consumer_offsets"} 9930

please review this PR

@atrbgithub
Copy link

This looks great 👍

@atrbgithub
Copy link

@xxm404 I've had a look at building on your code to make things a little faster as it was making a call for every partition, which was taking quite some time on a cluster with many topics/partitions.

Please see here

This builds a map of all the brokers and topics, with an array for each partition they own.

It then makes a single call for each broker with an array of topics and partitions which that broker is the leader for:

https://github.com/atrbgithub/kafka_exporter/blob/5923381978656a6fbeb91fb069c14f44ecb5f73e/kafka_exporter.go#L607

Not sure if you want to modify your PR to do something similar?

@soloradish
Copy link

soloradish commented Jun 28, 2022

It's better to follow the metric's naming convention.
Add a unit as this metric's suffix like kafka_topic_partition_size_bytes.

But I couldn't managed to find the right unit name in Kafka java client docs. Maybe you guys can figure it out ^-^

@xxm404 @atrbgithub

@turbotankist
Copy link

Any updates?

@soloradish
Copy link

soloradish commented Sep 19, 2023

Any updates?

You can use my build, https://github.com/soloradish/kafka_exporter

It expose the kafka_topic_partition_size_bytes metric. but be ware I remove all consumer related metrics, because I use kafka lag exporter for these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants