Skip to content

Commit

Permalink
Support node pool topic metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar committed Jul 17, 2024
1 parent 2f68da6 commit 4a770e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ui/api/kafka/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,14 @@ export async function getKafkaTopicMetrics(
async function getRangeByNodeId(
namespace: string,
name: string,
nodePools: string,
metric: TopicMetric,
) {
const start = new Date().getTime() - 1 * 60 * 60 * 1000;
const end = new Date();
const step = 60 * 1;
const seriesRes = await prom!.rangeQuery(
topic[metric](namespace, name),
topic[metric](namespace, name, nodePools),
start,
end,
step,
Expand Down Expand Up @@ -312,6 +313,7 @@ export async function getKafkaTopicMetrics(
getRangeByNodeId(
cluster.attributes.namespace,
cluster.attributes.name,
cluster.attributes.nodePools?.join("|") ?? "",
m,
),
),
Expand Down
17 changes: 13 additions & 4 deletions ui/api/kafka/topic.promql.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
export const incomingByteRate = (namespace: string, cluster: string) => `
export const incomingByteRate = (
namespace: string,
cluster: string,
nodePools: string,
) => `
sum by (__console_metric_name__) (
label_replace(
irate(kafka_server_brokertopicmetrics_bytesin_total{topic!="",namespace="${namespace}",pod=~"${cluster}-kafka-\\\\d+",strimzi_io_kind="Kafka"}[5m]),
irate(kafka_server_brokertopicmetrics_bytesin_total{topic!="",namespace="${namespace}",pod=~"${cluster}-(kafka|${nodePools})-\\\\d+",strimzi_io_kind="Kafka"}[5m]),
"__console_metric_name__",
"incoming_byte_rate",
"",
""
)
)
`;
export const outgoingByteRate = (namespace: string, cluster: string) => `

export const outgoingByteRate = (
namespace: string,
cluster: string,
nodePools: string,
) => `
sum by (__console_metric_name__) (
label_replace(
irate(kafka_server_brokertopicmetrics_bytesout_total{topic!="",namespace="${namespace}",pod=~"${cluster}-kafka-\\\\d+",strimzi_io_kind="Kafka"}[5m]),
irate(kafka_server_brokertopicmetrics_bytesout_total{topic!="",namespace="${namespace}",pod=~"${cluster}-(kafka|${nodePools})-\\\\d+",strimzi_io_kind="Kafka"}[5m]),
"__console_metric_name__",
"outgoing_byte_rate",
"",
Expand Down

0 comments on commit 4a770e4

Please sign in to comment.