Get topics for consumer group

This commit is contained in:
2023-07-26 22:12:23 +02:00
parent b37f50308d
commit 89d9357df3
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
defmodule KafkaexLagExporter.TopicNameParser do
@moduledoc "Parse Kafka internal member assignment payload in order to find which topics belong to the consumer group"
@invalid_topic_characters ~r/[^[:alnum:]\-\._]/
def parse_topic_names(member_assignment) do
member_assignment
|> String.chunk(:printable)
|> Enum.drop(1)
|> Enum.take_every(2)
|> Enum.map(fn topic_name -> Regex.replace(@invalid_topic_characters, topic_name, "") end)
end
end