Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -25897,7 +25897,6 @@
"xpack.metricsData.assetDetails.metrics.label.diskReadIOPS": "Entrées et sorties par seconde en lecture sur le disque",
"xpack.metricsData.assetDetails.metrics.label.diskReadThroughput": "Rendement de lecture du disque",
"xpack.metricsData.assetDetails.metrics.label.diskSpaceAvailable": "Espace disque disponible",
"xpack.metricsData.assetDetails.metrics.label.diskSpaceAvailablity": "Disponibilité de l'espace disque",
"xpack.metricsData.assetDetails.metrics.label.diskThroughput": "Rendement du disque",
"xpack.metricsData.assetDetails.metrics.label.diskUsage": "Utilisation du disque",
"xpack.metricsData.assetDetails.metrics.label.diskUsageAverage": "Utilisation moyenne du disque",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25928,7 +25928,6 @@
"xpack.metricsData.assetDetails.metrics.label.diskReadIOPS": "ディスク読み取りIOPS",
"xpack.metricsData.assetDetails.metrics.label.diskReadThroughput": "ディスク読み取りスループット",
"xpack.metricsData.assetDetails.metrics.label.diskSpaceAvailable": "空きディスク容量",
"xpack.metricsData.assetDetails.metrics.label.diskSpaceAvailablity": "空きディスク容量",
"xpack.metricsData.assetDetails.metrics.label.diskThroughput": "Disk Throughput",
"xpack.metricsData.assetDetails.metrics.label.diskUsage": "ディスク使用量",
"xpack.metricsData.assetDetails.metrics.label.diskUsageAverage": "ディスク使用量(平均)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25918,7 +25918,6 @@
"xpack.metricsData.assetDetails.metrics.label.diskReadIOPS": "磁盘读取 IOPS",
"xpack.metricsData.assetDetails.metrics.label.diskReadThroughput": "磁盘读取吞吐量",
"xpack.metricsData.assetDetails.metrics.label.diskSpaceAvailable": "可用磁盘空间",
"xpack.metricsData.assetDetails.metrics.label.diskSpaceAvailablity": "磁盘空间可用性",
"xpack.metricsData.assetDetails.metrics.label.diskThroughput": "磁盘吞吐量",
"xpack.metricsData.assetDetails.metrics.label.diskUsage": "磁盘使用率",
"xpack.metricsData.assetDetails.metrics.label.diskUsageAverage": "磁盘使用率平均值",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React from 'react';
import { EuiFlexItem } from '@elastic/eui';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import type { DataSchemaFormat } from '@kbn/metrics-data-access-plugin/common';
import { Kpi } from './kpi';
import { useHostKpiCharts } from '../../hooks/use_host_metrics_charts';

Expand All @@ -20,6 +21,8 @@ export interface HostKpiChartsProps {
lastReloadRequestTime?: number;
getSubtitle?: (formulaValue: string) => string;
loading?: boolean;

schema?: DataSchemaFormat | null;
}

export const HostKpiCharts = ({
Expand All @@ -30,10 +33,12 @@ export const HostKpiCharts = ({
query,
lastReloadRequestTime,
loading = false,
schema,
}: HostKpiChartsProps) => {
const charts = useHostKpiCharts({
dataViewId: dataView?.id,
getSubtitle,
schema,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { findInventoryModel } from '@kbn/metrics-data-access-plugin/common';
import { useMemo } from 'react';
import { DataSchemaFormat, findInventoryModel } from '@kbn/metrics-data-access-plugin/common';
import useAsync from 'react-use/lib/useAsync';
import type { HostMetricTypes } from '../charts/types';
import { useChartSeriesColor } from './use_chart_series_color';
Expand All @@ -16,13 +15,20 @@ export const useHostCharts = ({
metric,
dataViewId,
overview,
schema,
}: {
metric: HostMetricTypes;
dataViewId?: string;
overview?: boolean;
schema?: DataSchemaFormat | null;
}) => {
const { value: charts = [], error } = useAsync(async () => {
const hostCharts = await getHostsCharts({ metric, overview });
const hostCharts = await getHostsCharts({
metric,
overview,
schema: schema ?? DataSchemaFormat.ECS,
});

return hostCharts.map((chart) => ({
...chart,
...(dataViewId && {
Expand All @@ -31,30 +37,38 @@ export const useHostCharts = ({
},
}),
}));
}, [dataViewId, metric, overview]);
}, [dataViewId, metric, overview, schema]);

return { charts, error };
};

export const useKubernetesCharts = ({
dataViewId,
overview,
schema,
}: {
dataViewId?: string;
overview?: boolean;
schema?: DataSchemaFormat | null;
}) => {
const model = useMemo(() => findInventoryModel('host'), []);
const model = findInventoryModel('host');

const { value: charts = [], error } = useAsync(async () => {
const { kibernetesNode } = await model.metrics.getCharts();
const { kubernetesNode } = await model.metrics.getCharts({
schema: schema ?? DataSchemaFormat.ECS,
});

if (!kubernetesNode) {
return [];
}

const items = overview
? [kibernetesNode.xy.nodeCpuCapacity, kibernetesNode.xy.nodeMemoryCapacity]
? [kubernetesNode.xy.nodeCpuCapacity, kubernetesNode.xy.nodeMemoryCapacity]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg, good catch, how long have we been with this typo? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to Windsurf 😆 . It would've passed unnoticed again if it weren't for it.

: [
kibernetesNode.xy.nodeCpuCapacity,
kibernetesNode.xy.nodeMemoryCapacity,
kibernetesNode.xy.nodeDiskCapacity,
kibernetesNode.xy.nodePodCapacity,
kubernetesNode.xy.nodeCpuCapacity,
kubernetesNode.xy.nodeMemoryCapacity,
kubernetesNode.xy.nodeDiskCapacity,
kubernetesNode.xy.nodePodCapacity,
];

return items.map((chart) => {
Expand All @@ -67,7 +81,7 @@ export const useKubernetesCharts = ({
}),
};
});
}, [dataViewId, overview, model.metrics]);
}, [model.metrics, schema, overview, dataViewId]);

return { charts, error };
};
Expand All @@ -83,16 +97,20 @@ export const useHostKpiCharts = ({
dataViewId,
seriesColor,
getSubtitle,
schema,
}: {
dataViewId?: string;
seriesColor?: string;
getSubtitle?: (formulaValue: string) => string;
schema?: DataSchemaFormat | null;
}) => {
seriesColor = useChartSeriesColor(seriesColor);

const { value: charts = [] } = useAsync(async () => {
const model = findInventoryModel('host');
const { cpu, memory, disk } = await model.metrics.getCharts();
const { cpu, memory, disk } = await model.metrics.getCharts({
schema: schema ?? DataSchemaFormat.ECS,
});

return [
cpu.metric.cpuUsage,
Expand All @@ -110,20 +128,25 @@ export const useHostKpiCharts = ({
},
}),
}));
}, [dataViewId, seriesColor, getSubtitle]);
}, [dataViewId, seriesColor, getSubtitle, schema]);

return charts;
};

const getHostsCharts = async ({
metric,
overview,
schema,
}: {
metric: HostMetricTypes;
overview?: boolean;
schema?: DataSchemaFormat | null;
}) => {
const model = findInventoryModel('host');
const { cpu, memory, network, disk, logs } = await model.metrics.getCharts();

const { cpu, memory, network, disk, logs } = await model.metrics.getCharts({
schema: schema ?? DataSchemaFormat.ECS,
});

switch (metric) {
case 'cpu':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const KpiCharts = () => {
lastReloadRequestTime={afterLoadedState.reloadRequestTime}
getSubtitle={afterLoadedState.getSubtitle}
loading={loading}
schema={searchCriteria.preferredSchema}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ import { Chart } from './chart';
import { Popover } from '../../common/popover';
import { useMetricsDataViewContext } from '../../../../../../containers/metrics_source';
import { useMetricsCharts } from '../../../hooks/use_metrics_charts';
import { useUnifiedSearchContext } from '../../../hooks/use_unified_search';

export const MetricsGrid = () => {
const { metricsView } = useMetricsDataViewContext();
const charts = useMetricsCharts({ dataViewId: metricsView?.dataViewReference.id });
const { searchCriteria } = useUnifiedSearchContext();
const charts = useMetricsCharts({
dataViewId: metricsView?.dataViewReference.id,
schema: searchCriteria.preferredSchema,
});

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import useAsync from 'react-use/lib/useAsync';
import { isEqual } from 'lodash';
import { isNumber } from 'lodash/fp';
import type { CloudProvider } from '@kbn/custom-icons';
import { findInventoryModel } from '@kbn/metrics-data-access-plugin/common';
import { DataSchemaFormat, findInventoryModel } from '@kbn/metrics-data-access-plugin/common';
import { EuiToolTip } from '@elastic/eui';
import { EuiBadge } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
Expand All @@ -42,6 +42,7 @@ import { TABLE_COLUMN_LABEL, TABLE_CONTENT_LABEL } from '../translations';
import { METRICS_TOOLTIP } from '../../../../common/visualizations';
import { buildCombinedAssetFilter } from '../../../../utils/filters/build';
import { AddDataTroubleshootingPopover } from '../components/table/add_data_troubleshooting_popover';
import { useUnifiedSearchContext } from './use_unified_search';

/**
* Columns and items types
Expand Down Expand Up @@ -153,11 +154,18 @@ export const useHostsTable = () => {
const inventoryModel = findInventoryModel('host');
const [selectedItems, setSelectedItems] = useState<HostNodeRow[]>([]);
const { hostNodes } = useHostsViewContext();
const { searchCriteria } = useUnifiedSearchContext();

const displayAlerts = hostNodes.some((item) => 'alertsCount' in item);
const showApmHostTroubleshooting = hostNodes.some((item) => !item.hasSystemMetrics);

const { value: formulas } = useAsync(() => inventoryModel.metrics.getFormulas());
const { value: formulas } = useAsync(
() =>
inventoryModel.metrics.getFormulas({
schema: searchCriteria.preferredSchema ?? DataSchemaFormat.ECS,
}),
[inventoryModel.metrics, searchCriteria.preferredSchema]
);

const [{ detailsItemId, pagination, sorting }, setProperties] = useHostsTableUrlState();
const {
Expand Down Expand Up @@ -496,6 +504,7 @@ export const useHostsTable = () => {
align: 'right',
},
],

[
displayAlerts,
showApmHostTroubleshooting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@

import useAsync from 'react-use/lib/useAsync';
import type { LensBreakdownConfig } from '@kbn/lens-embeddable-utils/config_builder';
import { DataSchemaFormat } from '@kbn/metrics-data-access-plugin/common';
import { findInventoryModel } from '@kbn/metrics-data-access-plugin/common';
import { PAGE_SIZE_OPTIONS } from '../constants';

export const useMetricsCharts = ({ dataViewId }: { dataViewId?: string }) => {
export const useMetricsCharts = ({
dataViewId,
schema,
}: {
dataViewId?: string;
schema?: DataSchemaFormat | null;
}) => {
const { value: charts = [] } = useAsync(async () => {
const model = findInventoryModel('host');
const { cpu, disk, memory, network } = await model.metrics.getCharts();
const { cpu, disk, memory, network } = await model.metrics.getCharts({
schema: schema ?? DataSchemaFormat.ECS,
});

return [
cpu.xy.cpuUsage,
Expand Down Expand Up @@ -47,7 +56,7 @@ export const useMetricsCharts = ({ dataViewId }: { dataViewId?: string }) => {
},
}),
}));
}, [dataViewId]);
}, [schema, dataViewId]);

return charts;
};
Loading