Skip to content

Commit 46314a3

Browse files
committed
ui: avoid duplicate metrics for single-store nodes
When focused on a single node, some DB console graphs show per-store metrics with an additional graph aggregating across the node's stores. In the common case of a single-store node, the aggregated metric and the per-store metric are the same and make the graph more difficult to parse. This commit updates these graphs to only include the aggregated metric if a node has more than one store. Epic: none Release note: none
1 parent 262a1d6 commit 46314a3

File tree

1 file changed

+18
-10
lines changed
  • pkg/ui/workspaces/db-console/src/views/cluster/containers/nodeGraphs/dashboards

1 file changed

+18
-10
lines changed

pkg/ui/workspaces/db-console/src/views/cluster/containers/nodeGraphs/dashboards/storeUtils.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,29 @@ export const storeMetrics = (
5555
/>
5656
);
5757

58-
// show only the aggregated node-level metric when viewing multiple nodes
58+
// Show only the aggregated node-level metric when viewing multiple nodes.
5959
if (nodeIDs.length > 1) {
6060
return nodeMetric;
6161
}
6262

63-
// otherwise, show the aggregated metric and a per-store breakdown
63+
const perStoreMetrics = storeIDs.map(sid => (
64+
<Metric
65+
key={`${nid}-${sid}`}
66+
title={`${prefix} (n${nid},s${sid})`}
67+
sources={[sid]}
68+
{...props}
69+
/>
70+
));
71+
72+
// If there's only one store for the node, don't show both the aggregated
73+
// metric and the per-store breakdown which will always be equal.
74+
if (storeIDs.length == 1) {
75+
return perStoreMetrics;
76+
}
77+
78+
// Otherwise, show the aggregated metric and a per-store breakdown.
6479
return [
6580
nodeMetric,
66-
...storeIDs.map(sid => (
67-
<Metric
68-
key={`${nid}-${sid}`}
69-
title={`${prefix} (n${nid},s${sid})`}
70-
sources={[sid]}
71-
{...props}
72-
/>
73-
)),
81+
...perStoreMetrics,
7482
];
7583
});

0 commit comments

Comments
 (0)