diff --git a/frontend/src/pages/sys-admin/statistic/statistic-metrics.js b/frontend/src/pages/sys-admin/statistic/statistic-metrics.js
index 91657bee15..9a64553e6e 100644
--- a/frontend/src/pages/sys-admin/statistic/statistic-metrics.js
+++ b/frontend/src/pages/sys-admin/statistic/statistic-metrics.js
@@ -5,42 +5,51 @@ import MainPanelTopbar from '../main-panel-topbar';
import StatisticNav from './statistic-nav';
import { gettext } from '../../../utils/constants';
-class MetricCard extends Component {
+const MetricRow = ({ metric, point }) => (
+
+
+
+ |
+ {point.labels.node} |
+ {point.value} |
+ {dayjs(point.labels.collected_at).format('YYYY-MM-DD HH:mm:ss')} |
+
+);
+
+class ComponentMetricsTable extends Component {
render() {
- const { metric } = this.props;
+ const { componentName, metrics } = this.props;
+
return (
-
+
-
- {metric.name}
- {metric.type}
- {metric.help && (
-
- help:
- {metric.help}
-
- )}
-
+
+
+ {componentName}
+
-
+
- {gettext('Node')} |
- {gettext('Component')} |
- {gettext('Collected Time')} |
- {gettext('Value')} |
+ {gettext('Metric')} |
+ {gettext('Node')} |
+ {gettext('Value')} |
+ {gettext('Collected Time')} |
- {metric.data_points.map((point, index) => (
-
- {point.labels.node} |
- {point.labels.component} |
- {dayjs(point.labels.collected_at).format('YYYY-MM-DD HH:mm:ss')} |
- {point.value} |
-
+ {metrics.map((metric) => (
+ metric.data_points.map((point, pointIndex) => (
+
+ ))
))}
@@ -57,7 +66,8 @@ class StatisticMetrics extends Component {
this.state = {
metrics: [],
loading: true,
- error: null
+ error: null,
+ groupedMetrics: {}
};
}
@@ -65,12 +75,38 @@ class StatisticMetrics extends Component {
this.getMetrics();
}
+ groupMetricsByComponent = (metrics) => {
+ const groups = {};
+ metrics.forEach(metric => {
+ if (metric.data_points && metric.data_points.length > 0) {
+ metric.data_points.forEach(point => {
+ const component = point.labels.component || 'Other';
+ if (!groups[component]) {
+ groups[component] = [];
+ }
+ const existingMetric = groups[component].find(m => m.name === metric.name);
+ if (existingMetric) {
+ existingMetric.data_points.push(point);
+ } else {
+ groups[component].push({
+ ...metric,
+ data_points: [point]
+ });
+ }
+ });
+ }
+ });
+ return groups;
+ };
+
getMetrics = async () => {
this.setState({ loading: true });
try {
const res = await systemAdminAPI.sysAdminStatisticMetrics();
+ const groupedMetrics = this.groupMetricsByComponent(res.data.metrics);
this.setState({
metrics: res.data.metrics,
+ groupedMetrics,
loading: false
});
} catch (error) {
@@ -82,7 +118,7 @@ class StatisticMetrics extends Component {
};
render() {
- const { metrics, loading, error } = this.state;
+ const { groupedMetrics, loading, error } = this.state;
return (
<>
@@ -96,8 +132,12 @@ class StatisticMetrics extends Component {
{error}
) : (
- {metrics.map((metric, index) => (
-
+ {Object.entries(groupedMetrics).map(([component, metrics]) => (
+
))}
)}
@@ -110,57 +150,36 @@ class StatisticMetrics extends Component {
const style = `
`;