Skip to content

Commit

Permalink
fix: return empty metrics when prometheus requests fail (#1004)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar authored Aug 29, 2024
1 parent 68eb499 commit 1eef2e1
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ui/api/kafka/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ export async function getKafkaClusterKpis(
};
} catch (err) {
log.error({ err, clusterId }, "getKafkaClusterKpis");
throw new Error("getKafkaClusterKpis: couldn't connect with Prometheus");
return {
cluster,
kpis: null,
};
}
}

Expand Down Expand Up @@ -278,7 +281,10 @@ export async function getKafkaClusterMetrics(
};
} catch (err) {
log.error({ err, clusterId, metric: metrics }, "getKafkaClusterMetric");
throw new Error("getKafkaClusterMetric: couldn't connect with Prometheus");
return {
cluster,
ranges: null,
};
}
}

Expand Down Expand Up @@ -315,13 +321,13 @@ export async function getKafkaTopicMetrics(
return [metric, MetricRangeSchema.parse(serieByNode)];
}

try {
const cluster = await getKafkaCluster(clusterId);
const cluster = await getKafkaCluster(clusterId);

if (!cluster) {
return null;
}
if (!cluster) {
return null;
}

try {
if (!prom || !cluster.attributes.namespace) {
log.warn({ clusterId }, "getKafkaClusterKpis Prometheus unavailable");
return { cluster, ranges: null };
Expand Down Expand Up @@ -349,6 +355,9 @@ export async function getKafkaTopicMetrics(
};
} catch (err) {
log.error({ err, clusterId, metric: metrics }, "getKafkaTopicMetrics");
throw new Error("getKafkaTopicMetric: couldn't connect with Prometheus");
return {
cluster,
ranges: null,
};
}
}

0 comments on commit 1eef2e1

Please sign in to comment.